Add type hints to some handlers (#8505)

This commit is contained in:
Patrick Cloke 2020-10-09 07:20:51 -04:00 committed by GitHub
parent a97cec18bb
commit a93f3121f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 22 deletions

View file

@ -16,14 +16,18 @@
import logging
import re
from typing import TYPE_CHECKING
from synapse.api.errors import Codes, PasswordRefusedError
if TYPE_CHECKING:
from synapse.app.homeserver import HomeServer
logger = logging.getLogger(__name__)
class PasswordPolicyHandler:
def __init__(self, hs):
def __init__(self, hs: "HomeServer"):
self.policy = hs.config.password_policy
self.enabled = hs.config.password_policy_enabled
@ -33,11 +37,11 @@ class PasswordPolicyHandler:
self.regexp_uppercase = re.compile("[A-Z]")
self.regexp_lowercase = re.compile("[a-z]")
def validate_password(self, password):
def validate_password(self, password: str) -> None:
"""Checks whether a given password complies with the server's policy.
Args:
password (str): The password to check against the server's policy.
password: The password to check against the server's policy.
Raises:
PasswordRefusedError: The password doesn't comply with the server's policy.