Skip to content
Snippets Groups Projects
Unverified Commit 21bb50ca authored by Jonathan de Jong's avatar Jonathan de Jong Committed by GitHub
Browse files

Fix mypy error: auth handler "checkpw" internal function type mismatch (#8569)

parent 8f27b7fd
No related branches found
No related tags found
No related merge requests found
Fix mypy not properly checking across the codebase, additionally, fix a typing assertion error in `handlers/auth.py`.
\ No newline at end of file
......@@ -1122,20 +1122,22 @@ class AuthHandler(BaseHandler):
Whether self.hash(password) == stored_hash.
"""
def _do_validate_hash():
def _do_validate_hash(checked_hash: bytes):
# Normalise the Unicode in the password
pw = unicodedata.normalize("NFKC", password)
return bcrypt.checkpw(
pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"),
stored_hash,
checked_hash,
)
if stored_hash:
if not isinstance(stored_hash, bytes):
stored_hash = stored_hash.encode("ascii")
return await defer_to_thread(self.hs.get_reactor(), _do_validate_hash)
return await defer_to_thread(
self.hs.get_reactor(), _do_validate_hash, stored_hash
)
else:
return False
......
......@@ -158,7 +158,6 @@ commands=
coverage html
[testenv:mypy]
skip_install = True
deps =
{[base]deps}
mypy==0.782
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment