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

Fix twisted trunk mypy errors #14012

Merged
merged 4 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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