Skip to content

Commit 1a37498

Browse files
author
Fabien Coelho
committed
please mypy
1 parent 21f1488 commit 1a37498

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: CacheToolsUtils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class AutoPrefixedCache(PrefixedCache):
237237

238238
_COUNTER: int = 0
239239

240-
_METHODS = {
240+
_METHODS: dict[str, Callable[[Any], bytes]] = {
241241
"b64": base64.b64encode,
242242
"b64u": base64.urlsafe_b64encode,
243243
"b32": base64.b32encode,
@@ -249,9 +249,9 @@ class AutoPrefixedCache(PrefixedCache):
249249
}
250250

251251
def __init__(self, cache: MutableMapping, sep: str = ".", method: str = "b64"):
252-
encoder = AutoPrefixedCache._METHODS.get(method)
253-
if encoder is None:
252+
if method not in AutoPrefixedCache._METHODS:
254253
raise Exception(f"invalid conversion method: {method}")
254+
encoder = AutoPrefixedCache._METHODS[method]
255255
length = max(1, (AutoPrefixedCache._COUNTER.bit_length() + 7) // 8)
256256
# NOTE byteorder default added to 3.11
257257
prefix = encoder(AutoPrefixedCache._COUNTER.to_bytes(length, byteorder="big")).decode("ASCII")

0 commit comments

Comments
 (0)