From 7e10082c5cb6f4dc3807977af8165f376bd82b61 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 16 Oct 2019 22:11:22 -0600 Subject: [PATCH] Update mypy to 0.740 --- tildes/requirements.txt | 2 +- tildes/tildes/lib/url_transform.py | 4 ++++ tildes/tildes/models/message/message.py | 2 +- tildes/tildes/models/topic/topic.py | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tildes/requirements.txt b/tildes/requirements.txt index 8a871f2..a451995 100644 --- a/tildes/requirements.txt +++ b/tildes/requirements.txt @@ -34,7 +34,7 @@ MarkupSafe==1.1.1 marshmallow==2.20.5 mccabe==0.6.1 more-itertools==7.2.0 -mypy==0.730 +mypy==0.740 mypy-extensions==0.4.2 packaging==19.2 parso==0.5.1 diff --git a/tildes/tildes/lib/url_transform.py b/tildes/tildes/lib/url_transform.py index 6f1c7fe..85b449f 100644 --- a/tildes/tildes/lib/url_transform.py +++ b/tildes/tildes/lib/url_transform.py @@ -196,11 +196,15 @@ class WikipediaMobileConverter(UrlTransformer): @classmethod def is_applicable(cls, parsed_url: ParseResult) -> bool: """Return whether this transformation should be applied to the url.""" + assert parsed_url.hostname is not None # mypy workaround + return parsed_url.hostname.endswith(".m.wikipedia.org") and has_path(parsed_url) @classmethod def apply_transformation(cls, parsed_url: ParseResult) -> ParseResult: """Apply the actual transformation process to the url.""" + assert parsed_url.hostname is not None # mypy workaround + new_domain = parsed_url.hostname.replace(".m.wikipedia.org", ".wikipedia.org") return parsed_url._replace(netloc=new_domain) diff --git a/tildes/tildes/models/message/message.py b/tildes/tildes/models/message/message.py index 5df1109..6a48ff5 100644 --- a/tildes/tildes/models/message/message.py +++ b/tildes/tildes/models/message/message.py @@ -193,7 +193,7 @@ class MessageConversation(DatabaseModel): raise ValueError("User is not a participant in this conversation.") user_id = user.user_id - self.unread_user_ids = ( # type: ignore + self.unread_user_ids = ( MessageConversation.unread_user_ids - user_id # type: ignore ) diff --git a/tildes/tildes/models/topic/topic.py b/tildes/tildes/models/topic/topic.py index fd06e46..ed0c3e8 100644 --- a/tildes/tildes/models/topic/topic.py +++ b/tildes/tildes/models/topic/topic.py @@ -420,8 +420,8 @@ class Topic(DatabaseModel): return TopicContentType.TEXT if self.is_link_type: - parsed_url = urlparse(self.link) # type: ignore - url_path = PurePosixPath(parsed_url.path) + parsed_url = urlparse(self.link) + url_path = PurePosixPath(str(parsed_url.path)) if url_path.suffix.lower() == ".pdf": return TopicContentType.PDF