Skip to content

Commit e624afb

Browse files
committed
enable reportMissingTypeArgument
1 parent d904a17 commit e624afb

40 files changed

+450
-248
lines changed

pandas-stubs/_libs/interval.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ VALID_CLOSED: frozenset[str]
2525

2626
_OrderableScalarT = TypeVar("_OrderableScalarT", bound=int | float)
2727
_OrderableTimesT = TypeVar("_OrderableTimesT", bound=Timestamp | Timedelta)
28-
_OrderableT = TypeVar("_OrderableT", bound=int | float | Timestamp | Timedelta)
28+
_OrderableT = TypeVar(
29+
"_OrderableT", bound=int | float | Timestamp | Timedelta, default=Any
30+
)
2931

3032
@type_check_only
3133
class _LengthDescriptor:

pandas-stubs/_typing.pyi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ XMLParsers: TypeAlias = Literal["lxml", "etree"]
774774
HTMLFlavors: TypeAlias = Literal["lxml", "html5lib", "bs4"]
775775

776776
# Interval closed type
777-
IntervalT = TypeVar("IntervalT", bound=Interval)
777+
IntervalT = TypeVar("IntervalT", bound=Interval, default=Interval)
778778
IntervalLeftRight: TypeAlias = Literal["left", "right"]
779779
IntervalClosedType: TypeAlias = IntervalLeftRight | Literal["both", "neither"]
780780

@@ -958,7 +958,10 @@ np_1darray_dt: TypeAlias = np_1darray[np.datetime64]
958958
np_1darray_td: TypeAlias = np_1darray[np.timedelta64]
959959
np_2darray: TypeAlias = np.ndarray[tuple[int, int], np.dtype[GenericT]]
960960

961-
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray)
961+
if sys.version_info >= (3, 11):
962+
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray)
963+
else:
964+
NDArrayT = TypeVar("NDArrayT", bound=np.ndarray[Any, Any])
962965

963966
DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
964967
KeysArgType: TypeAlias = Any
@@ -1069,7 +1072,7 @@ if TYPE_CHECKING: # noqa: PYI002
10691072
| Scalar
10701073
| Period
10711074
| Interval[int | float | Timestamp | Timedelta]
1072-
| tuple,
1075+
| tuple[Any, ...],
10731076
)
10741077
# Use a distinct SeriesByT when using groupby with Series of known dtype.
10751078
# Essentially, an intersection between Series S1 TypeVar, and ByT TypeVar
@@ -1101,7 +1104,7 @@ GroupByObjectNonScalar: TypeAlias = (
11011104
| Grouper
11021105
| list[Grouper]
11031106
)
1104-
GroupByObject: TypeAlias = Scalar | Index | GroupByObjectNonScalar | Series
1107+
GroupByObject: TypeAlias = Scalar | Index | GroupByObjectNonScalar[_HashableTa] | Series
11051108

11061109
StataDateFormat: TypeAlias = Literal[
11071110
"tc",
@@ -1124,9 +1127,9 @@ StataDateFormat: TypeAlias = Literal[
11241127
# `DataFrame.replace` also accepts mappings of these.
11251128
ReplaceValue: TypeAlias = (
11261129
Scalar
1127-
| Pattern
1130+
| Pattern[Any]
11281131
| NAType
1129-
| Sequence[Scalar | Pattern]
1132+
| Sequence[Scalar | Pattern[Any]]
11301133
| Mapping[HashableT, ScalarT]
11311134
| Series
11321135
| None

pandas-stubs/core/arrays/base.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from collections.abc import (
22
Iterator,
33
Sequence,
44
)
5+
import sys
56
from typing import (
67
Any,
78
Literal,
@@ -55,8 +56,13 @@ class ExtensionArray:
5556
def ndim(self) -> int: ...
5657
@property
5758
def nbytes(self) -> int: ...
58-
@overload
59-
def astype(self, dtype: np.dtype, copy: bool = True) -> np_1darray: ...
59+
if sys.version_info >= (3, 11):
60+
@overload
61+
def astype(self, dtype: np.dtype, copy: bool = True) -> np_1darray: ...
62+
else:
63+
@overload
64+
def astype(self, dtype: np.dtype[Any], copy: bool = True) -> np_1darray: ...
65+
6066
@overload
6167
def astype(self, dtype: ExtensionDtype, copy: bool = True) -> ExtensionArray: ...
6268
@overload

pandas-stubs/core/arrays/datetimes.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from datetime import tzinfo as _tzinfo
2+
import sys
3+
from typing import Any
24

35
import numpy as np
46
from pandas.core.arrays.datetimelike import (
@@ -19,8 +21,13 @@ class DatetimeArray(DatetimeLikeArrayMixin, TimelikeOps, DatelikeOps):
1921
__array_priority__: int = ...
2022
def __init__(self, values, dtype=..., freq=..., copy: bool = ...) -> None: ...
2123
# ignore in dtype() is from the pandas source
22-
@property
23-
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
24+
if sys.version_info >= (3, 11):
25+
@property
26+
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
27+
else:
28+
@property
29+
def dtype(self) -> np.dtype[Any] | DatetimeTZDtype: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
30+
2431
@property
2532
def tz(self): ...
2633
@tz.setter

pandas-stubs/core/arrays/numpy_.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import sys
2+
from typing import Any
3+
14
import numpy as np
25
from numpy.lib.mixins import NDArrayOperatorsMixin
36
from pandas.core.arrays.base import (
@@ -8,8 +11,13 @@ from pandas.core.arrays.base import (
811
from pandas.core.dtypes.dtypes import ExtensionDtype
912

1013
class PandasDtype(ExtensionDtype):
11-
@property
12-
def numpy_dtype(self) -> np.dtype: ...
14+
if sys.version_info >= (3, 11):
15+
@property
16+
def numpy_dtype(self) -> np.dtype: ...
17+
else:
18+
@property
19+
def numpy_dtype(self) -> np.dtype[Any]: ...
20+
1321
@property
1422
def itemsize(self) -> int: ...
1523

pandas-stubs/core/computation/ops.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any
23

34
import numpy as np
@@ -75,8 +76,12 @@ class UnaryOp(Op):
7576
func = ...
7677
def __init__(self, op: str, operand) -> None: ...
7778
def __call__(self, env): ...
78-
@property
79-
def return_type(self) -> np.dtype: ...
79+
if sys.version_info >= (3, 11):
80+
@property
81+
def return_type(self) -> np.dtype: ...
82+
else:
83+
@property
84+
def return_type(self) -> np.dtype[Any]: ...
8085

8186
class MathCall(Op):
8287
func = ...

pandas-stubs/core/construction.pyi

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from collections.abc import Sequence
2-
from typing import overload
2+
import sys
3+
from typing import (
4+
Any,
5+
overload,
6+
)
37

48
import numpy as np
59
from pandas.core.arrays.base import ExtensionArray
@@ -40,9 +44,19 @@ def array(
4044
dtype: PandasFloatDtypeArg | None = None,
4145
copy: bool = True,
4246
) -> FloatingArray: ...
43-
@overload
44-
def array(
45-
data: Sequence[object],
46-
dtype: str | np.dtype | ExtensionDtype | None = None,
47-
copy: bool = True,
48-
) -> ExtensionArray: ...
47+
48+
if sys.version_info >= (3, 11):
49+
@overload
50+
def array(
51+
data: Sequence[object],
52+
dtype: str | np.dtype | ExtensionDtype | None = None,
53+
copy: bool = True,
54+
) -> ExtensionArray: ...
55+
56+
else:
57+
@overload
58+
def array(
59+
data: Sequence[object],
60+
dtype: str | np.dtype[Any] | ExtensionDtype | None = None,
61+
copy: bool = True,
62+
) -> ExtensionArray: ...

pandas-stubs/core/dtypes/dtypes.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime as dt
2+
import sys
23
from typing import (
34
Any,
45
Literal,
@@ -59,5 +60,9 @@ class PeriodDtype(PandasExtensionDtype):
5960

6061
class IntervalDtype(PandasExtensionDtype):
6162
def __init__(self, subtype: str | npt.DTypeLike | None = ...) -> None: ...
62-
@property
63-
def subtype(self) -> np.dtype | None: ...
63+
if sys.version_info >= (3, 11):
64+
@property
65+
def subtype(self) -> np.dtype | None: ...
66+
else:
67+
@property
68+
def subtype(self) -> np.dtype[Any] | None: ...

0 commit comments

Comments
 (0)