Skip to content

Commit 9bf345a

Browse files
Merge branch 'main' into gh1327_date_timedelta_range
2 parents 584e288 + 766cc1d commit 9bf345a

File tree

17 files changed

+2311
-181
lines changed

17 files changed

+2311
-181
lines changed

pandas-stubs/_libs/tslibs/offsets.pyi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class ApplyTypeError(TypeError): ...
2929
class BaseOffset:
3030
n: int
3131
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
32-
def __eq__(self, other) -> bool: ...
33-
def __ne__(self, other) -> bool: ...
32+
def __eq__(self, other: object) -> bool: ...
33+
def __ne__(self, other: object) -> bool: ...
3434
def __hash__(self) -> int: ...
3535
@property
36-
def kwds(self) -> dict: ...
36+
def kwds(self) -> dict[str, Any]: ...
3737
@property
3838
def base(self) -> BaseOffset: ...
3939
@overload
@@ -67,7 +67,6 @@ class BaseOffset:
6767
def __rsub__(self, other: BaseOffset) -> Self: ...
6868
@overload
6969
def __rsub__(self, other: _TimedeltaT) -> _TimedeltaT: ...
70-
def __call__(self, other): ...
7170
@overload
7271
def __mul__(self, other: np.ndarray) -> np.ndarray: ...
7372
@overload
@@ -87,8 +86,6 @@ class BaseOffset:
8786
def rollback(self, dt: datetime) -> datetime: ...
8887
def rollforward(self, dt: datetime) -> datetime: ...
8988
def is_on_offset(self, dt: datetime) -> bool: ...
90-
def __setstate__(self, state) -> None: ...
91-
def __getstate__(self): ...
9289
@property
9390
def nanos(self) -> int: ...
9491

pandas-stubs/_typing.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from re import Pattern
1515
import sys
1616
from typing import (
1717
Any,
18+
Generic,
1819
Literal,
1920
Protocol,
2021
SupportsIndex,
@@ -37,6 +38,7 @@ from typing_extensions import (
3738
ParamSpec,
3839
TypeAlias,
3940
TypeVar,
41+
override,
4042
)
4143

4244
from pandas._libs.interval import Interval
@@ -818,6 +820,8 @@ np_ndarray_float: TypeAlias = npt.NDArray[np.floating]
818820
np_ndarray_complex: TypeAlias = npt.NDArray[np.complexfloating]
819821
np_ndarray_bool: TypeAlias = npt.NDArray[np.bool_]
820822
np_ndarray_str: TypeAlias = npt.NDArray[np.str_]
823+
np_ndarray_dt: TypeAlias = npt.NDArray[np.datetime64]
824+
np_ndarray_td: TypeAlias = npt.NDArray[np.timedelta64]
821825

822826
# Define shape and generic type variables with defaults similar to numpy
823827
GenericT = TypeVar("GenericT", bound=np.generic, default=Any)
@@ -1055,4 +1059,14 @@ DictConvertible: TypeAlias = FulldatetimeDict | DataFrame
10551059
# where it is the only acceptable type.
10561060
Incomplete: TypeAlias = Any
10571061

1062+
# differentiating between bool and int/float/complex
1063+
# https://github.com/pandas-dev/pandas-stubs/pull/1312#pullrequestreview-3126128971
1064+
class Just(Protocol, Generic[T]):
1065+
@property # type: ignore[override]
1066+
@override
1067+
def __class__(self, /) -> type[T]: ...
1068+
@__class__.setter
1069+
@override
1070+
def __class__(self, t: type[T], /) -> None: ...
1071+
10581072
__all__ = ["npt", "type_t"]

pandas-stubs/core/arrays/base.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Iterator
12
from typing import (
23
Any,
34
overload,
@@ -23,16 +24,16 @@ class ExtensionArray:
2324
def __getitem__(self, item: ScalarIndexer) -> Any: ...
2425
@overload
2526
def __getitem__(self, item: SequenceIndexer) -> Self: ...
26-
def __setitem__(self, key: int | slice | np.ndarray, value) -> None: ...
27+
def __setitem__(self, key: int | slice | np.ndarray, value: Any) -> None: ...
2728
def __len__(self) -> int: ...
28-
def __iter__(self): ...
29+
def __iter__(self) -> Iterator[Any]: ...
2930
def __contains__(self, item: object) -> bool | np.bool_: ...
3031
def to_numpy(
3132
self,
3233
dtype: npt.DTypeLike | None = ...,
3334
copy: bool = False,
3435
na_value: Scalar = ...,
35-
) -> np_1darray: ...
36+
) -> np_1darray[Any]: ...
3637
@property
3738
def dtype(self) -> ExtensionDtype: ...
3839
@property

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ from pandas._typing import (
7474
from pandas.plotting import PlotAccessor
7575

7676
_ResamplerGroupBy: TypeAlias = (
77-
DatetimeIndexResamplerGroupby[NDFrameT] # ty: ignore
78-
| PeriodIndexResamplerGroupby[NDFrameT] # ty: ignore
79-
| TimedeltaIndexResamplerGroupby[NDFrameT] # ty: ignore
77+
DatetimeIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
78+
| PeriodIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
79+
| TimedeltaIndexResamplerGroupby[NDFrameT] # ty: ignore[invalid-argument-type]
8080
)
8181

8282
class GroupBy(BaseGroupBy[NDFrameT]):

0 commit comments

Comments
 (0)