Browse Source

Update mypy to 0.740

merge-requests/85/head
Deimos 5 years ago
parent
commit
7e10082c5c
  1. 2
      tildes/requirements.txt
  2. 4
      tildes/tildes/lib/url_transform.py
  3. 2
      tildes/tildes/models/message/message.py
  4. 4
      tildes/tildes/models/topic/topic.py

2
tildes/requirements.txt

@ -34,7 +34,7 @@ MarkupSafe==1.1.1
marshmallow==2.20.5 marshmallow==2.20.5
mccabe==0.6.1 mccabe==0.6.1
more-itertools==7.2.0 more-itertools==7.2.0
mypy==0.730
mypy==0.740
mypy-extensions==0.4.2 mypy-extensions==0.4.2
packaging==19.2 packaging==19.2
parso==0.5.1 parso==0.5.1

4
tildes/tildes/lib/url_transform.py

@ -196,11 +196,15 @@ class WikipediaMobileConverter(UrlTransformer):
@classmethod @classmethod
def is_applicable(cls, parsed_url: ParseResult) -> bool: def is_applicable(cls, parsed_url: ParseResult) -> bool:
"""Return whether this transformation should be applied to the url.""" """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) return parsed_url.hostname.endswith(".m.wikipedia.org") and has_path(parsed_url)
@classmethod @classmethod
def apply_transformation(cls, parsed_url: ParseResult) -> ParseResult: def apply_transformation(cls, parsed_url: ParseResult) -> ParseResult:
"""Apply the actual transformation process to the url.""" """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") new_domain = parsed_url.hostname.replace(".m.wikipedia.org", ".wikipedia.org")
return parsed_url._replace(netloc=new_domain) return parsed_url._replace(netloc=new_domain)

2
tildes/tildes/models/message/message.py

@ -193,7 +193,7 @@ class MessageConversation(DatabaseModel):
raise ValueError("User is not a participant in this conversation.") raise ValueError("User is not a participant in this conversation.")
user_id = user.user_id user_id = user.user_id
self.unread_user_ids = ( # type: ignore
self.unread_user_ids = (
MessageConversation.unread_user_ids - user_id # type: ignore MessageConversation.unread_user_ids - user_id # type: ignore
) )

4
tildes/tildes/models/topic/topic.py

@ -420,8 +420,8 @@ class Topic(DatabaseModel):
return TopicContentType.TEXT return TopicContentType.TEXT
if self.is_link_type: 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": if url_path.suffix.lower() == ".pdf":
return TopicContentType.PDF return TopicContentType.PDF

Loading…
Cancel
Save