Linting fixes

This commit is contained in:
Carl Beekhuizen 2020-02-26 16:03:15 +00:00
parent a97cc000a0
commit 96cf6911ae
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5
4 changed files with 4 additions and 6 deletions

View File

@ -12,7 +12,4 @@ test:
. venv/bin/activate; cd ./src; python -m pytest
lint:
. venv/bin/activate; \
cd ./src
flake8 --ignore=E252,W504,W503 --max-line-length=120 . \
&& mypy --follow-imports=skip --ignore-missing-imports .
. venv/bin/activate; flake8 --ignore=E252,W504,W503 --max-line-length=120 ./src/ && mypy --follow-imports=skip --ignore-missing-imports ./src/

0
src/tests/__init__.py Normal file
View File

View File

@ -8,6 +8,7 @@ from key_derivation.mnemonic import (
with open('tests/test_key_derivation/test_vectors/mnemonic.json', 'r') as f:
test_vectors = load(f)
@pytest.mark.parametrize(
'language,language_test_vectors',
[(a, b) for a, b in test_vectors.items()]

View File

@ -25,8 +25,8 @@ def scrypt(*, password: str, salt: str, n: int, r: int, p: int, dklen: int) -> b
def PBKDF2(*, password: str, salt: bytes, dklen: int, c: int, prf: str) -> bytes:
assert('sha' in prf)
_hash = _sha256 if 'sha256' in prf else _sha512
password = password.encode("utf-8")
res = _PBKDF2(password=password, salt=salt, dkLen=dklen, count=c, hmac_hash_module=_hash)
password_bytes = password.encode("utf-8")
res = _PBKDF2(password=password_bytes, salt=salt, dkLen=dklen, count=c, hmac_hash_module=_hash) # type: ignore
return res if isinstance(res, bytes) else res[0] # PyCryptodome can return Tuple[bytes]