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

Commit

Permalink
Use assertion rather than cast
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Oct 3, 2022
1 parent a37e8e5 commit 149fecc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions synapse/handlers/cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ 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
# Cast safety: Error.response is Optional[bytes]. but a PartialDownloadError
# always has a non-None response.
body = cast(bytes, pde.response)
# 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 = (
'Authorization server responded with a "{status}" error '
Expand Down

0 comments on commit 149fecc

Please sign in to comment.