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): ...@@ -1122,20 +1122,22 @@ class AuthHandler(BaseHandler):
Whether self.hash(password) == stored_hash. Whether self.hash(password) == stored_hash.
""" """
def _do_validate_hash(): def _do_validate_hash(checked_hash: bytes):
# Normalise the Unicode in the password # Normalise the Unicode in the password
pw = unicodedata.normalize("NFKC", password) pw = unicodedata.normalize("NFKC", password)
return bcrypt.checkpw( return bcrypt.checkpw(
pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"), pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"),
stored_hash, checked_hash,
) )
if stored_hash: if stored_hash:
if not isinstance(stored_hash, bytes): if not isinstance(stored_hash, bytes):
stored_hash = stored_hash.encode("ascii") 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: else:
return False return False
......
...@@ -158,7 +158,6 @@ commands= ...@@ -158,7 +158,6 @@ commands=
coverage html coverage html
[testenv:mypy] [testenv:mypy]
skip_install = True
deps = deps =
{[base]deps} {[base]deps}
mypy==0.782 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