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

Commit a423f45

Browse files
author
David Robertson
authored
Fix twisted trunk mypy errors (#14012)
1 parent 7f4f2a3 commit a423f45

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

changelog.d/14012.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix type annotations to be compatible with new annotations in development versions of twisted.

synapse/handlers/cas.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ async def _validate_ticket(
130130
except PartialDownloadError as pde:
131131
# Twisted raises this error if the connection is closed,
132132
# even if that's being used old-http style to signal end-of-data
133+
# Assertion is for mypy's benefit. Error.response is Optional[bytes],
134+
# but a PartialDownloadError should always have a non-None response.
135+
assert pde.response is not None
133136
body = pde.response
134137
except HttpResponseException as e:
135138
description = (

synapse/handlers/ui_auth/checkers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ async def check_auth(self, authdict: dict, clientip: str) -> Any:
119119
except PartialDownloadError as pde:
120120
# Twisted is silly
121121
data = pde.response
122+
# For mypy's benefit. A general Error.response is Optional[bytes], but
123+
# a PartialDownloadError.response should be bytes AFAICS.
124+
assert data is not None
122125
resp_body = json_decoder.decode(data.decode("utf-8"))
123126

124127
if "success" in resp_body:

0 commit comments

Comments
 (0)