소스 검색

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

tags/v1.22.0rc1
Jonathan de Jong 3 년 전
committed by GitHub
부모
커밋
21bb50ca3f
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
3개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. +1
    -0
      changelog.d/8569.misc
  2. +5
    -3
      synapse/handlers/auth.py
  3. +0
    -1
      tox.ini

+ 1
- 0
changelog.d/8569.misc 파일 보기

@@ -0,0 +1 @@
Fix mypy not properly checking across the codebase, additionally, fix a typing assertion error in `handlers/auth.py`.

+ 5
- 3
synapse/handlers/auth.py 파일 보기

@@ -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



+ 0
- 1
tox.ini 파일 보기

@@ -158,7 +158,6 @@ commands=
coverage html

[testenv:mypy]
skip_install = True
deps =
{[base]deps}
mypy==0.782


불러오는 중...
취소
저장