Skip to content

Commit

Permalink
fix: use strict mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jul 20, 2023
1 parent 1a1c68c commit e86dddb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ exclude_lines = [
]

[tool.mypy]
strict = true
python_version = "3.8"
files = ["src/otpauth"]
show_error_codes = true
Expand Down
5 changes: 3 additions & 2 deletions src/otpauth/rfc4226.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ def generate_hotp(secret: bytes, counter: int, digit: int = 6, algorithm: Suppor
digest = hmac.new(secret, msg, hash_alg).digest()
offset = digest[19] & 0xF
bin_code: int = struct.unpack(">I", digest[offset: offset + 4])[0]
base = bin_code & 0x7FFFFFFF
return base % (10**digit)
total: int = bin_code & 0x7FFFFFFF
power: int = 10 ** digit
return total % power
2 changes: 1 addition & 1 deletion src/otpauth/rfc6238.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generate_totp(
period: int = 30,
timestamp: t.Optional[int] = None,
digit: int = 6,
algorithm: SupportedAlgorithms = "SHA1"):
algorithm: SupportedAlgorithms = "SHA1") -> int:
"""Generate a TOTP code.
A TOTP code is an extension of TOTP algorithm.
Expand Down

0 comments on commit e86dddb

Please sign in to comment.