Skip to content

Commit e86dddb

Browse files
committed
fix: use strict mypy
1 parent 1a1c68c commit e86dddb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ exclude_lines = [
6565
]
6666

6767
[tool.mypy]
68+
strict = true
6869
python_version = "3.8"
6970
files = ["src/otpauth"]
7071
show_error_codes = true

src/otpauth/rfc4226.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ def generate_hotp(secret: bytes, counter: int, digit: int = 6, algorithm: Suppor
6161
digest = hmac.new(secret, msg, hash_alg).digest()
6262
offset = digest[19] & 0xF
6363
bin_code: int = struct.unpack(">I", digest[offset: offset + 4])[0]
64-
base = bin_code & 0x7FFFFFFF
65-
return base % (10**digit)
64+
total: int = bin_code & 0x7FFFFFFF
65+
power: int = 10 ** digit
66+
return total % power

src/otpauth/rfc6238.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def generate_totp(
5757
period: int = 30,
5858
timestamp: t.Optional[int] = None,
5959
digit: int = 6,
60-
algorithm: SupportedAlgorithms = "SHA1"):
60+
algorithm: SupportedAlgorithms = "SHA1") -> int:
6161
"""Generate a TOTP code.
6262
6363
A TOTP code is an extension of TOTP algorithm.

0 commit comments

Comments
 (0)