Skip to content

Commit 8e3bd8c

Browse files
authored
🩹 python-version-dependent @override for __getstate__ (#317)
1 parent 77eaff0 commit 8e3bd8c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

‎src/numpy-stubs/polynomial/_polybase.pyi

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import abc
2+
import sys
23
from collections.abc import Iterator, Mapping, Sequence
34
from typing import Any, ClassVar, Final, Literal, SupportsIndex, TypeAlias, overload
45
from typing_extensions import Self, TypeIs, TypeVar, override
@@ -96,7 +97,14 @@ class ABCPolyBase(abc.ABC):
9697
def __rdivmod__(self, x: _AnyOther, /) -> tuple[Self, Self]: ...
9798
def __len__(self, /) -> int: ...
9899
def __iter__(self, /) -> Iterator[np.inexact | object]: ...
99-
def __getstate__(self, /) -> dict[str, Any]: ...
100+
101+
if sys.version_info >= (3, 11):
102+
@override
103+
def __getstate__(self, /) -> dict[str, Any]: ...
104+
105+
else:
106+
def __getstate__(self, /) -> dict[str, Any]: ...
107+
100108
def __setstate__(self, dict: dict[str, Any], /) -> None: ...
101109

102110
#

‎src/numpy-stubs/random/_generator.pyi

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import builtins
2+
import sys
23
from collections.abc import Callable
34
from typing import Any, Literal, TypeAlias, overload
45
from typing_extensions import TypeVar, override
@@ -61,10 +62,19 @@ _ToRNG: TypeAlias = (
6162

6263
class Generator:
6364
def __init__(self, /, bit_generator: BitGenerator[Any]) -> None: ...
64-
def __getstate__(self) -> None: ...
65+
66+
if sys.version_info >= (3, 11):
67+
@override
68+
def __getstate__(self) -> None: ...
69+
70+
else:
71+
def __getstate__(self) -> None: ...
72+
6573
def __setstate__(self, state: dict[str, Any] | None) -> None: ...
6674
@override
6775
def __reduce__(self) -> tuple[Callable[[BitGenerator], Generator], tuple[BitGenerator], None]: ...
76+
77+
#
6878
@property
6979
def bit_generator(self) -> BitGenerator: ...
7080
def spawn(self, /, n_children: int) -> list[Generator]: ...

‎src/numpy-stubs/random/mtrand.pyi

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import builtins
2+
import sys
23
from collections.abc import Callable
34
from typing import Any, Final, Literal, TypeAlias, overload
45
from typing_extensions import TypeVar, override
@@ -94,10 +95,19 @@ class RandomState:
9495
_bit_generator: Final[BitGenerator]
9596

9697
def __init__(self, /, seed: _ArrayLikeInt_co | BitGenerator[Any] | None = ...) -> None: ...
97-
def __getstate__(self) -> dict[str, Any]: ...
98+
99+
if sys.version_info >= (3, 11):
100+
@override
101+
def __getstate__(self) -> dict[str, Any]: ...
102+
103+
else:
104+
def __getstate__(self) -> dict[str, Any]: ...
105+
98106
def __setstate__(self, /, state: dict[str, Any]) -> None: ...
99107
@override
100108
def __reduce__(self) -> tuple[Callable[[BitGenerator], RandomState], tuple[BitGenerator], dict[str, Any]]: ...
109+
110+
#
101111
@overload
102112
def get_state(self, /, legacy: Literal[False]) -> dict[str, Any]: ...
103113
@overload

0 commit comments

Comments
 (0)