Skip to content

Commit 23d371a

Browse files
author
Release Manager
committed
gh-41092: tweak annotations for cachefunc so that mypy does not complain ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #41092 Reported by: Frédéric Chapoton Reviewer(s): Tobias Diez
2 parents 469417b + 487df77 commit 23d371a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/sage/misc/cachefunc.pyi

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Dict, Tuple, Union
1+
from typing import Any, Callable, Dict, Tuple
22

33
def dict_key(o: Any) -> Any:
44
...
@@ -7,7 +7,9 @@ def cache_key(o: Any) -> Any:
77
...
88

99
class CachedFunction:
10-
def __init__(self, f: Callable, classmethod: bool = False, name: str = None, key: Callable = None, do_pickle: bool = None) -> None:
10+
def __init__(self, f: Callable, classmethod: bool = False,
11+
name: str | None = None, key: Callable | None = None,
12+
do_pickle: bool | None = None) -> None:
1113
...
1214

1315
def __call__(self, *args: Any, **kwds: Any) -> Any:
@@ -35,7 +37,9 @@ class CachedFunction:
3537
...
3638

3739
class CachedMethod:
38-
def __init__(self, f: Callable, name: str = None, key: Callable = None, do_pickle: bool = None) -> None:
40+
def __init__(self, f: Callable, name: str | None = None,
41+
key: Callable | None = None,
42+
do_pickle: bool | None = None) -> None:
3943
...
4044

4145
def __call__(self, inst: Any, *args: Any, **kwds: Any) -> Any:
@@ -51,7 +55,9 @@ class CacheDict(dict):
5155
pass
5256

5357
class CachedInParentMethod(CachedMethod):
54-
def __init__(self, f: Callable, name: str = None, key: Callable = None, do_pickle: bool = None) -> None:
58+
def __init__(self, f: Callable, name: str | None = None,
59+
key: Callable | None = None,
60+
do_pickle: bool | None = None) -> None:
5561
...
5662

5763
def _get_instance_cache(self, inst: Any) -> Dict:
@@ -61,7 +67,10 @@ class CachedInParentMethod(CachedMethod):
6167
...
6268

6369
class CachedMethodCaller(CachedFunction):
64-
def __init__(self, cachedmethod: CachedMethod, inst: Any, cache: Dict = None, name: str = None, key: Callable = None, do_pickle: bool = None) -> None:
70+
def __init__(self, cachedmethod: CachedMethod, inst: Any,
71+
cache: Dict | None = None, name: str | None = None,
72+
key: Callable | None = None,
73+
do_pickle: bool | None = None) -> None:
6574
...
6675

6776
def _instance_call(self, *args: Any, **kwds: Any) -> Any:
@@ -80,7 +89,9 @@ class CachedMethodCaller(CachedFunction):
8089
...
8190

8291
class CachedMethodCallerNoArgs(CachedFunction):
83-
def __init__(self, inst: Any, f: Callable, cache: Any = None, name: str = None, do_pickle: bool = None) -> None:
92+
def __init__(self, inst: Any, f: Callable, cache: Any = None,
93+
name: str | None = None,
94+
do_pickle: bool | None = None) -> None:
8495
...
8596

8697
def _instance_call(self) -> Any:

0 commit comments

Comments
 (0)