mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-19 10:24:12 -04:00
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.
This commit is contained in:
parent
437961744c
commit
b3590614da
35 changed files with 194 additions and 295 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue