Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix twisted trunk mypy errors (#14012)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson authored Oct 3, 2022
1 parent 7f4f2a3 commit a423f45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/14012.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix type annotations to be compatible with new annotations in development versions of twisted.
3 changes: 3 additions & 0 deletions synapse/handlers/cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ async def _validate_ticket(
except PartialDownloadError as pde:
# Twisted raises this error if the connection is closed,
# even if that's being used old-http style to signal end-of-data
# Assertion is for mypy's benefit. Error.response is Optional[bytes],
# but a PartialDownloadError should always have a non-None response.
assert pde.response is not None
body = pde.response
except HttpResponseException as e:
description = (
Expand Down
3 changes: 3 additions & 0 deletions synapse/handlers/ui_auth/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ async def check_auth(self, authdict: dict, clientip: str) -> Any:
except PartialDownloadError as pde:
# Twisted is silly
data = pde.response
# For mypy's benefit. A general Error.response is Optional[bytes], but
# a PartialDownloadError.response should be bytes AFAICS.
assert data is not None
resp_body = json_decoder.decode(data.decode("utf-8"))

if "success" in resp_body:
Expand Down

0 comments on commit a423f45

Please sign in to comment.