From 149fecc88413ed6b5e64b7f3a870baf01bb81284 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 3 Oct 2022 13:46:01 +0100 Subject: [PATCH] Use assertion rather than cast --- synapse/handlers/cas.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/synapse/handlers/cas.py b/synapse/handlers/cas.py index e75d2d8a6140..7eaccea584ba 100644 --- a/synapse/handlers/cas.py +++ b/synapse/handlers/cas.py @@ -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 '