Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

use strings as immutable default arguments #162

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pyotp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .totp import TOTP as TOTP


def random_base32(length: int = 32, chars: Sequence[str] = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")) -> str:
def random_base32(length: int = 32, chars: Sequence[str] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567") -> str:
# Note: the otpauth scheme DOES NOT use base32 padding for secret lengths not divisible by 8.
# Some third-party tools have bugs when dealing with such secrets.
# We might consider warning the user when generating a secret of length not divisible by 8.
Expand All @@ -20,7 +20,7 @@ def random_base32(length: int = 32, chars: Sequence[str] = list("ABCDEFGHIJKLMNO
return "".join(random.choice(chars) for _ in range(length))


def random_hex(length: int = 40, chars: Sequence[str] = list("ABCDEF0123456789")) -> str:
def random_hex(length: int = 40, chars: Sequence[str] = "ABCDEF0123456789") -> str:
if length < 40:
raise ValueError("Secrets should be at least 160 bits")
return random_base32(length=length, chars=chars)
Expand Down
Loading