From b3e3e5a21dff7c692a3d82e5e30dba6e0ed4061f Mon Sep 17 00:00:00 2001 From: Benjamin DeVries Date: Tue, 26 Mar 2024 12:37:07 -0400 Subject: [PATCH] use strings as immutable default arguments --- src/pyotp/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyotp/__init__.py b/src/pyotp/__init__.py index a695790..c0e1155 100644 --- a/src/pyotp/__init__.py +++ b/src/pyotp/__init__.py @@ -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. @@ -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)