summary refs log tree commit diff
path: root/synapse/handlers/cas.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-09-20 08:56:23 -0400
committerGitHub <noreply@github.com>2021-09-20 08:56:23 -0400
commitb3590614da7e3e17e75530a9d4808df17be9b127 (patch)
treec57aaff95611f6ca47fc9355602fac304c4d8a5a /synapse/handlers/cas.py
parentFix remove_stale_pushers job on SQLite. (#10843) (diff)
downloadsynapse-b3590614da7e3e17e75530a9d4808df17be9b127.tar.xz
Require type hints in the handlers module. (#10831)
Adds missing type hints to methods in the synapse.handlers
module and requires all methods to have type hints there.

This also removes the unused construct_auth_difference method
from the FederationHandler.
Diffstat (limited to 'synapse/handlers/cas.py')
-rw-r--r--synapse/handlers/cas.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/synapse/handlers/cas.py b/synapse/handlers/cas.py
index 47ddabbe46..b0b188dc78 100644
--- a/synapse/handlers/cas.py
+++ b/synapse/handlers/cas.py
@@ -34,20 +34,20 @@ logger = logging.getLogger(__name__)
 class CasError(Exception):
     """Used to catch errors when validating the CAS ticket."""
 
-    def __init__(self, error, error_description=None):
+    def __init__(self, error: str, error_description: Optional[str] = None):
         self.error = error
         self.error_description = error_description
 
-    def __str__(self):
+    def __str__(self) -> str:
         if self.error_description:
             return f"{self.error}: {self.error_description}"
         return self.error
 
 
-@attr.s(slots=True, frozen=True)
+@attr.s(slots=True, frozen=True, auto_attribs=True)
 class CasResponse:
-    username = attr.ib(type=str)
-    attributes = attr.ib(type=Dict[str, List[Optional[str]]])
+    username: str
+    attributes: Dict[str, List[Optional[str]]]
 
 
 class CasHandler:
@@ -133,11 +133,9 @@ class CasHandler:
             body = pde.response
         except HttpResponseException as e:
             description = (
-                (
-                    'Authorization server responded with a "{status}" error '
-                    "while exchanging the authorization code."
-                ).format(status=e.code),
-            )
+                'Authorization server responded with a "{status}" error '
+                "while exchanging the authorization code."
+            ).format(status=e.code)
             raise CasError("server_error", description) from e
 
         return self._parse_cas_response(body)