Skip to content

Commit 331a861

Browse files
committed
enable reportMissingTypeArgument
1 parent d904a17 commit 331a861

30 files changed

+266
-192
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: 5 additions & 5 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

@@ -1069,7 +1069,7 @@ if TYPE_CHECKING: # noqa: PYI002
10691069
| Scalar
10701070
| Period
10711071
| Interval[int | float | Timestamp | Timedelta]
1072-
| tuple,
1072+
| tuple[Any, ...],
10731073
)
10741074
# Use a distinct SeriesByT when using groupby with Series of known dtype.
10751075
# Essentially, an intersection between Series S1 TypeVar, and ByT TypeVar
@@ -1101,7 +1101,7 @@ GroupByObjectNonScalar: TypeAlias = (
11011101
| Grouper
11021102
| list[Grouper]
11031103
)
1104-
GroupByObject: TypeAlias = Scalar | Index | GroupByObjectNonScalar | Series
1104+
GroupByObject: TypeAlias = Scalar | Index | GroupByObjectNonScalar[_HashableTa] | Series
11051105

11061106
StataDateFormat: TypeAlias = Literal[
11071107
"tc",
@@ -1124,9 +1124,9 @@ StataDateFormat: TypeAlias = Literal[
11241124
# `DataFrame.replace` also accepts mappings of these.
11251125
ReplaceValue: TypeAlias = (
11261126
Scalar
1127-
| Pattern
1127+
| Pattern[Any]
11281128
| NAType
1129-
| Sequence[Scalar | Pattern]
1129+
| Sequence[Scalar | Pattern[Any]]
11301130
| Mapping[HashableT, ScalarT]
11311131
| Series
11321132
| None

pandas-stubs/core/frame.pyi

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ from pandas.plotting import PlotAccessor
178178
from pandas.plotting._core import _BoxPlotT
179179

180180
_T_MUTABLE_MAPPING_co = TypeVar(
181-
"_T_MUTABLE_MAPPING_co", bound=MutableMapping, covariant=True
181+
"_T_MUTABLE_MAPPING_co", bound=MutableMapping[Any, Any], covariant=True
182182
)
183183

184184
class _iLocIndexerFrame(_iLocIndexer, Generic[_T]):
@@ -484,7 +484,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
484484
self,
485485
orient: str = ...,
486486
*,
487-
into: type[defaultdict],
487+
into: type[defaultdict[Any, Any]],
488488
index: Literal[True] = True,
489489
) -> Never: ...
490490
@overload
@@ -500,7 +500,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
500500
self,
501501
orient: Literal["records"],
502502
*,
503-
into: type[dict] = ...,
503+
into: type[dict[Any, Any]] = ...,
504504
index: Literal[True] = True,
505505
) -> list[dict[Hashable, Any]]: ...
506506
@overload
@@ -516,23 +516,23 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
516516
self,
517517
orient: Literal["index"],
518518
*,
519-
into: OrderedDict | type[OrderedDict],
519+
into: OrderedDict[Any, Any] | type[OrderedDict[Any, Any]],
520520
index: Literal[True] = True,
521521
) -> OrderedDict[Hashable, dict[Hashable, Any]]: ...
522522
@overload
523523
def to_dict(
524524
self,
525525
orient: Literal["index"],
526526
*,
527-
into: type[MutableMapping],
527+
into: type[MutableMapping[Any, Any]],
528528
index: Literal[True] = True,
529529
) -> MutableMapping[Hashable, dict[Hashable, Any]]: ...
530530
@overload
531531
def to_dict(
532532
self,
533533
orient: Literal["index"],
534534
*,
535-
into: type[dict] = ...,
535+
into: type[dict[Any, Any]] = ...,
536536
index: Literal[True] = True,
537537
) -> dict[Hashable, dict[Hashable, Any]]: ...
538538
@overload
@@ -548,23 +548,23 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
548548
self,
549549
orient: Literal["dict", "list", "series"] = ...,
550550
*,
551-
into: type[dict] = ...,
551+
into: type[dict[Any, Any]] = ...,
552552
index: Literal[True] = True,
553553
) -> dict[Hashable, Any]: ...
554554
@overload
555555
def to_dict(
556556
self,
557557
orient: Literal["split", "tight"],
558558
*,
559-
into: MutableMapping[Any, Any] | type[MutableMapping],
559+
into: MutableMapping[Any, Any] | type[MutableMapping[Any, Any]],
560560
index: bool = ...,
561561
) -> MutableMapping[str, list[Any]]: ...
562562
@overload
563563
def to_dict(
564564
self,
565565
orient: Literal["split", "tight"],
566566
*,
567-
into: type[dict] = ...,
567+
into: type[dict[Any, Any]] = ...,
568568
index: bool = ...,
569569
) -> dict[str, list[Any]]: ...
570570
@classmethod
@@ -1052,21 +1052,33 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
10521052
@overload
10531053
def replace(
10541054
self,
1055-
to_replace: ReplaceValue | Mapping[HashableT2, ReplaceValue] = ...,
1056-
value: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
1055+
to_replace: (
1056+
ReplaceValue[Any, Any] | Mapping[HashableT2, ReplaceValue[Any, Any]]
1057+
) = ...,
1058+
value: (
1059+
ReplaceValue[Any, Any] | Mapping[HashableT3, ReplaceValue[Any, Any]]
1060+
) = ...,
10571061
*,
10581062
inplace: Literal[True],
1059-
regex: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
1063+
regex: (
1064+
ReplaceValue[Any, Any] | Mapping[HashableT3, ReplaceValue[Any, Any]]
1065+
) = ...,
10601066
# TODO: pandas-dev/pandas#63195 return Self after Pandas 3.0
10611067
) -> None: ...
10621068
@overload
10631069
def replace(
10641070
self,
1065-
to_replace: ReplaceValue | Mapping[HashableT2, ReplaceValue] = ...,
1066-
value: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
1071+
to_replace: (
1072+
ReplaceValue[Any, Any] | Mapping[HashableT2, ReplaceValue[Any, Any]]
1073+
) = ...,
1074+
value: (
1075+
ReplaceValue[Any, Any] | Mapping[HashableT3, ReplaceValue[Any, Any]]
1076+
) = ...,
10671077
*,
10681078
inplace: Literal[False] = False,
1069-
regex: ReplaceValue | Mapping[HashableT3, ReplaceValue] = ...,
1079+
regex: (
1080+
ReplaceValue[Any, Any] | Mapping[HashableT3, ReplaceValue[Any, Any]]
1081+
) = ...,
10701082
) -> Self: ...
10711083
def shift(
10721084
self,
@@ -1381,7 +1393,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13811393
dropna: _bool = ...,
13821394
) -> DataFrameGroupBy[Period, Literal[False]]: ...
13831395
@overload
1384-
def groupby( # pyright: ignore reportOverlappingOverload
1396+
def groupby(
13851397
self,
13861398
by: IntervalIndex[IntervalT],
13871399
level: IndexLabel | None = ...,
@@ -1394,7 +1406,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13941406
@overload
13951407
def groupby(
13961408
self,
1397-
by: IntervalIndex[IntervalT],
1409+
by: IntervalIndex,
13981410
level: IndexLabel | None = ...,
13991411
as_index: Literal[False] = False,
14001412
sort: _bool = ...,
@@ -1405,7 +1417,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14051417
@overload
14061418
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
14071419
self,
1408-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1420+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14091421
level: IndexLabel | None = ...,
14101422
as_index: Literal[True] = True,
14111423
sort: _bool = ...,
@@ -1416,7 +1428,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14161428
@overload
14171429
def groupby( # type: ignore[overload-overlap]
14181430
self,
1419-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1431+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14201432
level: IndexLabel | None = ...,
14211433
as_index: Literal[False] = False,
14221434
sort: _bool = ...,
@@ -1477,11 +1489,17 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14771489
) -> Self: ...
14781490
def pivot_table(
14791491
self,
1480-
values: _PivotTableValuesTypes = None,
1481-
index: _PivotTableIndexTypes = None,
1482-
columns: _PivotTableColumnsTypes = None,
1492+
values: _PivotTableValuesTypes[
1493+
Any # ty: ignore[invalid-type-arguments]
1494+
] = None,
1495+
index: _PivotTableIndexTypes[Any] = None, # ty: ignore[invalid-type-arguments]
1496+
columns: _PivotTableColumnsTypes[
1497+
Any # ty: ignore[invalid-type-arguments]
1498+
] = None,
14831499
aggfunc: (
1484-
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
1500+
_PivotAggFunc[Any]
1501+
| Sequence[_PivotAggFunc[Any]]
1502+
| Mapping[Hashable, _PivotAggFunc[Any]]
14851503
) = "mean",
14861504
fill_value: Scalar | None = None,
14871505
margins: _bool = False,
@@ -1876,7 +1894,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18761894
@overload
18771895
def boxplot(
18781896
self,
1879-
by: Hashable | ListLikeHashable,
1897+
by: Hashable | ListLikeHashable[Any],
18801898
ax: PlotAxes | None = None,
18811899
fontsize: float | _str | None = None,
18821900
rot: float = 0,
@@ -1891,7 +1909,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18911909
@overload
18921910
def boxplot(
18931911
self,
1894-
by: Hashable | ListLikeHashable,
1912+
by: Hashable | ListLikeHashable[Any],
18951913
ax: PlotAxes | None = None,
18961914
fontsize: float | _str | None = None,
18971915
rot: float = 0,
@@ -2634,7 +2652,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
26342652
**kwargs: Any,
26352653
) -> Series: ...
26362654
# Not actually positional, but used to handle removal of deprecated
2637-
def set_axis(self, labels: AxesData, *, axis: Axis = 0) -> Self: ...
2655+
def set_axis(self, labels: AxesData[Any], *, axis: Axis = 0) -> Self: ...
26382656
def skew(
26392657
self,
26402658
axis: Axis | None = ...,
@@ -2863,8 +2881,12 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
28632881
def __rfloordiv__(
28642882
self, other: float | DataFrame | Series[int] | Series[float] | Sequence[float]
28652883
) -> Self: ...
2866-
def __truediv__(self, other: float | DataFrame | Series | Sequence) -> Self: ...
2867-
def __rtruediv__(self, other: float | DataFrame | Series | Sequence) -> Self: ...
2884+
def __truediv__(
2885+
self, other: float | DataFrame | Series | Sequence[Any]
2886+
) -> Self: ...
2887+
def __rtruediv__(
2888+
self, other: float | DataFrame | Series | Sequence[Any]
2889+
) -> Self: ...
28682890
@final
28692891
def __bool__(self) -> NoReturn: ...
28702892

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from collections.abc import (
77
)
88
import datetime as dt
99
from typing import (
10+
TYPE_CHECKING,
1011
Any,
1112
Concatenate,
1213
Generic,
@@ -70,11 +71,12 @@ from pandas._typing import (
7071

7172
from pandas.plotting import PlotAccessor
7273

73-
_ResamplerGroupBy: TypeAlias = (
74-
DatetimeIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
75-
| PeriodIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
76-
| TimedeltaIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
77-
)
74+
if TYPE_CHECKING: # noqa: PYI002
75+
_ResamplerGroupBy: TypeAlias = (
76+
DatetimeIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
77+
| PeriodIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
78+
| TimedeltaIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
79+
)
7880

7981
class GroupBy(BaseGroupBy[NDFrameT]):
8082
def __getattr__(self, attr: str) -> Any: ...
@@ -338,7 +340,7 @@ class GroupBy(BaseGroupBy[NDFrameT]):
338340
random_state: RandomState | None = ...,
339341
) -> NDFrameT: ...
340342

341-
_GroupByT = TypeVar("_GroupByT", bound=GroupBy)
343+
_GroupByT = TypeVar("_GroupByT", bound=GroupBy[Any])
342344

343345
# GroupByPlot does not really inherit from PlotAccessor but it delegates
344346
# to it using __call__ and __getattr__. We lie here to avoid repeating the
@@ -383,15 +385,15 @@ class BaseGroupBy(SelectionMixin[NDFrameT], GroupByIndexingMixin):
383385
@final
384386
def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]: ...
385387
@overload
386-
def __getitem__(self: BaseGroupBy[DataFrame], key: Scalar) -> generic.SeriesGroupBy: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
388+
def __getitem__(self: BaseGroupBy[DataFrame], key: Scalar) -> generic.SeriesGroupBy[Any, Any]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
387389
@overload
388390
def __getitem__(
389391
self: BaseGroupBy[DataFrame], key: Iterable[Hashable]
390-
) -> generic.DataFrameGroupBy: ...
392+
) -> generic.DataFrameGroupBy[Any, Any]: ...
391393
@overload
392394
def __getitem__(
393395
self: BaseGroupBy[Series[S1]],
394396
idx: list[str] | Index | Series[S1] | MaskType | tuple[Hashable | slice, ...],
395-
) -> generic.SeriesGroupBy: ...
397+
) -> generic.SeriesGroupBy[Any, Any]: ...
396398
@overload
397399
def __getitem__(self: BaseGroupBy[Series[S1]], idx: Scalar) -> S1: ...

pandas-stubs/core/indexes/accessors.pyi

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from datetime import (
55
tzinfo as _tzinfo,
66
)
77
from typing import (
8+
Any,
89
Generic,
910
Literal,
1011
TypeVar,
@@ -377,7 +378,7 @@ class PeriodProperties(
377378
Series[Timestamp], Series[int], Series[str], DatetimeArray, PeriodArray
378379
],
379380
_DatetimeFieldOps[Series[int]],
380-
_IsLeapYearProperty,
381+
_IsLeapYearProperty[_DTBoolOpsReturnType],
381382
_FreqProperty[BaseOffset],
382383
): ...
383384
class CombinedDatetimelikeProperties(
@@ -393,7 +394,9 @@ class CombinedDatetimelikeProperties(
393394
Series[Period],
394395
],
395396
_TimedeltaPropertiesNoRounding[Series[int], Series[float]],
396-
_PeriodProperties,
397+
_PeriodProperties[
398+
Series[Timestamp], Series[int], Series[str], DatetimeArray, PeriodArray
399+
],
397400
): ...
398401

399402
@type_check_only
@@ -458,7 +461,7 @@ class DtDescriptor:
458461
@overload
459462
def __get__(
460463
self, instance: Series[Period], owner: type[Series]
461-
) -> PeriodProperties: ...
464+
) -> PeriodProperties[Any]: ...
462465

463466
@type_check_only
464467
class ArrayDescriptor:

0 commit comments

Comments
 (0)