Skip to content

Commit 1dd9599

Browse files
committed
Change typing on CacheTransformer to reflect that mutation of kwargs shouldn't happen
1 parent f9ad58f commit 1dd9599

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/async_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__author__ = "Michael Hall"
1010
__license__ = "Apache-2.0"
1111
__copyright__ = "Copyright 2020-Present Michael Hall"
12-
__version__ = "2025.07.07b"
12+
__version__ = "2025.07.08b"
1313

1414
import os
1515
import sys

src/async_utils/_paramkey.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import annotations
1616

17-
from collections.abc import Hashable
17+
from collections.abc import Hashable, Mapping
1818

1919
from . import _typings as t
2020

@@ -40,7 +40,7 @@ def __eq__(self, other: object, /) -> bool:
4040
_marker: tuple[object] = (object(),)
4141

4242

43-
def make_key(args: tuple[t.Any, ...], kwds: dict[t.Any, t.Any], /) -> Hashable:
43+
def make_key(args: tuple[t.Any, ...], kwds: Mapping[t.Any, object], /) -> Hashable:
4444
key: tuple[t.Any, ...] = args
4545
if kwds:
4646
key += _marker

src/async_utils/corofunc_cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import asyncio
1818
import concurrent.futures as cf
19-
from collections.abc import Awaitable, Callable, Coroutine, Hashable
19+
from collections.abc import Awaitable, Callable, Coroutine, Hashable, Mapping
2020
from functools import partial, wraps
2121

2222
from . import _typings as t
@@ -32,7 +32,7 @@
3232
#: rather than a ParamSpec of the decorated function.
3333
#: Warning: Mutations will impact callsite, return new objects as needed.
3434
type CacheTransformer = Callable[
35-
[tuple[t.Any, ...], dict[str, t.Any]], tuple[tuple[t.Any, ...], dict[str, t.Any]]
35+
[tuple[t.Any, ...], Mapping[str, t.Any]], tuple[tuple[t.Any, ...], Mapping[str, t.Any]]
3636
]
3737

3838
TYPE_CHECKING = False

src/async_utils/task_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import asyncio
1818
import concurrent.futures as cf
19-
from collections.abc import Callable, Coroutine, Hashable
19+
from collections.abc import Callable, Coroutine, Hashable, Mapping
2020
from functools import partial, wraps
2121

2222
from . import _typings as t
@@ -29,11 +29,11 @@
2929
type TaskFunc[**P, R] = Callable[P, asyncio.Task[R]]
3030
type TaskCoroFunc[**P, R] = CoroFunc[P, R] | TaskFunc[P, R]
3131

32-
#: Note CacheTransformers recieve a tuple (args) and dict(kwargs)
32+
#: Note CacheTransformers recieve a tuple (args) and dict (kwargs)
3333
#: rather than a ParamSpec of the decorated function.
3434
#: Warning: Mutations will impact callsite, return new objects as needed.
3535
type CacheTransformer = Callable[
36-
[tuple[t.Any, ...], dict[str, t.Any]], tuple[tuple[t.Any, ...], dict[str, t.Any]]
36+
[tuple[t.Any, ...], Mapping[str, t.Any]], tuple[tuple[t.Any, ...], Mapping[str, t.Any]]
3737
]
3838

3939
TYPE_CHECKING = False

0 commit comments

Comments
 (0)