Skip to content

Commit af44ad4

Browse files
committed
Merge remote-tracking branch 'upstream/main' into scalars-interval
2 parents 794a577 + b7163c2 commit af44ad4

25 files changed

+571
-42
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/asottile/pyupgrade
14-
rev: v2.37.3
14+
rev: v3.2.0
1515
hooks:
1616
- id: pyupgrade
1717
types_or: [python, pyi]
@@ -27,7 +27,7 @@ repos:
2727
- id: flake8
2828
name: flake8 (pyi)
2929
additional_dependencies:
30-
- flake8-pyi==22.8.2
30+
- flake8-pyi==22.10.0
3131
types: [pyi]
3232
args: [
3333
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y027 Y034 Y037 Y041 Y042,

pandas-stubs/_libs/tslibs/offsets.pyi

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import (
22
date,
33
datetime,
4+
time,
45
timedelta,
56
)
67
from typing import (
@@ -78,6 +79,7 @@ class BaseOffset:
7879
def name(self) -> str: ...
7980
@property
8081
def rule_code(self) -> str: ...
82+
@property
8183
def freqstr(self) -> str: ...
8284
def apply_index(self, dtindex: DatetimeIndex) -> DatetimeIndex: ...
8385
def rollback(self, dt: datetime) -> datetime: ...
@@ -131,8 +133,8 @@ class BusinessHour(BusinessMixin):
131133
self,
132134
n: int = ...,
133135
normalize: bool = ...,
134-
start: str | Collection[str] = ...,
135-
end: str | Collection[str] = ...,
136+
start: str | time | Collection[str | time] = ...,
137+
end: str | time | Collection[str | time] = ...,
136138
offset: timedelta = ...,
137139
): ...
138140

@@ -217,8 +219,8 @@ class CustomBusinessHour(BusinessHour):
217219
self,
218220
n: int = ...,
219221
normalize: bool = ...,
220-
start: str = ...,
221-
end: str = ...,
222+
start: str | time | Collection[str | time] = ...,
223+
end: str | time | Collection[str | time] = ...,
222224
offset: timedelta = ...,
223225
holidays: list | None = ...,
224226
): ...

pandas-stubs/_testing/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def assert_series_equal(
7474
obj: str = ...,
7575
*,
7676
check_index: Literal[False],
77-
check_like: Literal[False],
77+
check_like: Literal[False] = ...,
7878
) -> None: ...
7979
@overload
8080
def assert_series_equal(

pandas-stubs/core/base.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class IndexOpsMixin:
6363
def tolist(self) -> list: ...
6464
def to_list(self) -> list: ...
6565
def __iter__(self): ...
66+
@property
6667
def hasnans(self) -> bool: ...
6768
def value_counts(
6869
self,

pandas-stubs/core/dtypes/common.pyi

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ from pandas.core.dtypes.inference import (
2828
is_scalar as is_scalar,
2929
)
3030

31-
_ArrayOrDtype: TypeAlias = Union[ArrayLike, npt.DTypeLike, pd.Series, pd.DataFrame]
31+
_ArrayOrDtype: TypeAlias = Union[
32+
ArrayLike, npt.DTypeLike, pd.Series, pd.DataFrame, pd.Index
33+
]
3234

3335
def is_object_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
3436
def is_sparse(arr: ArrayLike | pd.Series | pd.DataFrame) -> bool: ...

pandas-stubs/core/frame.pyi

+1-3
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,6 @@ class DataFrame(NDFrame, OpsMixin):
12761276
@property
12771277
def at(self): ... # Not sure what to do with this yet; look at source
12781278
@property
1279-
def bool(self) -> _bool: ...
1280-
@property
12811279
def columns(self) -> Index: ...
12821280
@columns.setter # setter needs to be right next to getter; otherwise mypy complains
12831281
def columns(
@@ -1359,7 +1357,7 @@ class DataFrame(NDFrame, OpsMixin):
13591357
) -> DataFrame: ...
13601358
def astype(
13611359
self,
1362-
dtype: _str | Dtype | dict[_str, _str | Dtype],
1360+
dtype: _str | Dtype | dict[_str, _str | Dtype] | Series,
13631361
copy: _bool = ...,
13641362
errors: _str = ...,
13651363
) -> DataFrame: ...

pandas-stubs/core/generic.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from typing import (
88
Literal,
99
Mapping,
1010
Sequence,
11+
final,
1112
overload,
1213
)
1314

@@ -83,6 +84,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
8384
def __neg__(self: NDFrameT) -> NDFrameT: ...
8485
def __pos__(self: NDFrameT) -> NDFrameT: ...
8586
def __nonzero__(self) -> None: ...
87+
@final
8688
def bool(self) -> _bool: ...
8789
def __abs__(self) -> NDFrame: ...
8890
def __round__(self, decimals: int = ...) -> NDFrame: ...

pandas-stubs/core/groupby/ops.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class BinGrouper(BaseGrouper):
7070
def get_iterator(self, data: DataFrame | Series, axis: int = ...): ...
7171
def indices(self): ...
7272
def group_info(self): ...
73+
@property
7374
def reconstructed_codes(self) -> list[np.ndarray]: ...
7475
def result_index(self): ...
7576
@property

pandas-stubs/core/indexes/base.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Index(IndexOpsMixin, PandasObject):
112112
def is_monotonic_increasing(self) -> bool: ...
113113
@property
114114
def is_monotonic_decreasing(self) -> bool: ...
115+
@property
115116
def is_unique(self) -> bool: ...
116117
@property
117118
def has_duplicates(self) -> bool: ...
@@ -124,9 +125,10 @@ class Index(IndexOpsMixin, PandasObject):
124125
def is_interval(self) -> bool: ...
125126
def is_mixed(self) -> bool: ...
126127
def holds_integer(self): ...
128+
@property
127129
def inferred_type(self): ...
128-
def is_all_dates(self) -> bool: ...
129130
def __reduce__(self): ...
131+
@property
130132
def hasnans(self) -> bool: ...
131133
def isna(self): ...
132134
isnull = ...
@@ -177,6 +179,7 @@ class Index(IndexOpsMixin, PandasObject):
177179
): ...
178180
@property
179181
def values(self) -> np.ndarray: ...
182+
@property
180183
def array(self) -> ExtensionArray: ...
181184
def memory_usage(self, deep: bool = ...): ...
182185
def where(self, cond, other=...): ...

pandas-stubs/core/indexes/category.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CategoricalIndex(ExtensionIndex, accessor.PandasDelegate):
2828
def __array__(self, dtype=...) -> np.ndarray: ...
2929
def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ...
3030
def fillna(self, value=..., downcast=...): ...
31+
@property
3132
def is_unique(self) -> bool: ...
3233
@property
3334
def is_monotonic_increasing(self) -> bool: ...

pandas-stubs/core/indexes/multi.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ class MultiIndex(Index):
6565
def __array__(self, dtype=...) -> np.ndarray: ...
6666
def view(self, cls=...): ...
6767
def __contains__(self, key) -> bool: ...
68+
@property
6869
def dtype(self) -> np.dtype: ...
6970
def memory_usage(self, deep: bool = ...) -> int: ...
71+
@property
7072
def nbytes(self) -> int: ...
7173
def format(
7274
self,
@@ -82,7 +84,9 @@ class MultiIndex(Index):
8284
def inferred_type(self) -> str: ...
8385
@property
8486
def values(self): ...
87+
@property
8588
def is_monotonic_increasing(self) -> bool: ...
89+
@property
8690
def is_monotonic_decreasing(self) -> bool: ...
8791
def duplicated(self, keep: Literal["first", "last", False] = ...): ...
8892
def fillna(self, value=..., downcast=...) -> None: ...

pandas-stubs/core/indexes/numeric.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ class Float64Index(NumericIndex):
3737
def equals(self, other) -> bool: ...
3838
def __contains__(self, other) -> bool: ...
3939
def get_loc(self, key, tolerance=...): ...
40+
@property
4041
def is_unique(self) -> bool: ...
4142
def isin(self, values, level=...): ...

pandas-stubs/core/indexes/range.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ class RangeIndex(Int64Index):
3232
def start(self): ...
3333
def stop(self): ...
3434
def step(self): ...
35+
@property
3536
def nbytes(self) -> int: ...
3637
def memory_usage(self, deep: bool = ...) -> int: ...
3738
@property
3839
def dtype(self) -> np.dtype: ...
3940
@property
4041
def is_unique(self) -> bool: ...
42+
@property
4143
def is_monotonic_increasing(self) -> bool: ...
44+
@property
4245
def is_monotonic_decreasing(self) -> bool: ...
4346
@property
4447
def has_duplicates(self) -> bool: ...

pandas-stubs/core/series.pyi

+32-10
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ from pandas.core.window.rolling import (
6262
Rolling,
6363
Window,
6464
)
65-
from typing_extensions import TypeAlias
65+
from typing_extensions import (
66+
Never,
67+
TypeAlias,
68+
)
6669
import xarray as xr
6770

6871
from pandas._libs.missing import NAType
@@ -467,8 +470,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
467470
observed: _bool = ...,
468471
dropna: _bool = ...,
469472
) -> _SeriesGroupByNonScalar[S1]: ...
473+
# need the ignore because None is Hashable
470474
@overload
471-
def count(self, level: None = ...) -> int: ...
475+
def count(self, level: None = ...) -> int: ... # type: ignore[misc]
472476
@overload
473477
def count(self, level: Hashable) -> Series[S1]: ...
474478
def mode(self, dropna=...) -> Series[S1]: ...
@@ -1222,7 +1226,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
12221226
def __add__(self, other: Timestamp) -> TimestampSeries: ...
12231227
@overload
12241228
def __add__(
1225-
self, other: num | _str | Timedelta | _ListLike | Series[S1]
1229+
self, other: num | _str | Timedelta | _ListLike | Series[S1] | np.timedelta64
12261230
) -> Series: ...
12271231
# ignore needed for mypy as we want different results based on the arguments
12281232
@overload
@@ -1254,7 +1258,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
12541258
def __le__(self, other: S1 | _ListLike | Series[S1]) -> Series[_bool]: ...
12551259
def __lt__(self, other: S1 | _ListLike | Series[S1]) -> Series[_bool]: ...
12561260
@overload
1257-
def __mul__(self, other: Timedelta | TimedeltaSeries) -> TimedeltaSeries: ...
1261+
def __mul__(
1262+
self, other: Timedelta | TimedeltaSeries | np.timedelta64
1263+
) -> TimedeltaSeries: ...
12581264
@overload
12591265
def __mul__(self, other: num | _ListLike | Series) -> Series: ...
12601266
def __mod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
@@ -1315,17 +1321,19 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
13151321
) -> TimedeltaSeries: ...
13161322
@overload
13171323
def __sub__(
1318-
self: Series[Timestamp], other: Timedelta | TimedeltaSeries | TimedeltaIndex
1324+
self: Series[Timestamp],
1325+
other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64,
13191326
) -> TimestampSeries: ...
13201327
@overload
13211328
def __sub__(
1322-
self: Series[Timedelta], other: Timedelta | TimedeltaSeries | TimedeltaIndex
1329+
self: Series[Timedelta],
1330+
other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64,
13231331
) -> TimedeltaSeries: ...
13241332
@overload
13251333
def __sub__(self, other: num | _ListLike | Series) -> Series: ...
13261334
@overload
13271335
def __truediv__(
1328-
self, other: Timedelta | TimedeltaSeries | TimedeltaIndex
1336+
self, other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64
13291337
) -> Series[float]: ...
13301338
@overload
13311339
def __truediv__(self, other: num | _ListLike | Series[S1]) -> Series: ...
@@ -1750,6 +1758,14 @@ class TimestampSeries(Series[Timestamp]):
17501758
# ignore needed because of mypy
17511759
@property
17521760
def dt(self) -> TimestampProperties: ... # type: ignore[override]
1761+
@overload # type: ignore[override]
1762+
def __add__(
1763+
self, other: TimedeltaSeries | np.timedelta64 | TimestampSeries
1764+
) -> TimestampSeries: ...
1765+
@overload
1766+
def __add__(self, other: Timestamp) -> Never: ...
1767+
def __mul__(self, other: TimestampSeries | np.timedelta64 | TimedeltaSeries) -> Never: ... # type: ignore[override]
1768+
def __truediv__(self, other: TimestampSeries | np.timedelta64 | TimedeltaSeries) -> Never: ... # type: ignore[override]
17531769

17541770
class TimedeltaSeries(Series[Timedelta]):
17551771
# ignores needed because of mypy
@@ -1758,12 +1774,18 @@ class TimedeltaSeries(Series[Timedelta]):
17581774
@overload
17591775
def __add__(self, other: Timestamp | DatetimeIndex) -> TimestampSeries: ...
17601776
@overload
1761-
def __add__(self, other: Timedelta) -> TimedeltaSeries: ...
1777+
def __add__(self, other: Timedelta | np.timedelta64) -> TimedeltaSeries: ...
17621778
def __radd__(self, pther: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override]
1763-
def __mul__(self, other: num) -> TimedeltaSeries: ... # type: ignore[override]
1779+
@overload # type: ignore[override]
1780+
def __mul__(
1781+
self, other: TimestampSeries | np.timedelta64 | Timedelta | TimedeltaSeries
1782+
) -> Never: ...
1783+
@overload
1784+
def __mul__(self, other: num) -> TimedeltaSeries: ...
17641785
def __sub__( # type: ignore[override]
1765-
self, other: Timedelta | TimedeltaSeries | TimedeltaIndex
1786+
self, other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64
17661787
) -> TimedeltaSeries: ...
1788+
def __truediv__(self, other: TimedeltaSeries | np.timedelta64 | TimedeltaIndex) -> Series[float]: ... # type: ignore[override]
17671789
@property
17681790
def dt(self) -> TimedeltaProperties: ... # type: ignore[override]
17691791

pandas-stubs/core/strings.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class StringMethods(NoNewAttributesMixin, Generic[T, _TS]):
142142
def get_dummies(self, sep: str = ...) -> pd.DataFrame: ...
143143
def translate(self, table: dict[int, int | str | None] | None) -> T: ...
144144
def count(self, pat: str, flags: int = ...) -> Series[int]: ...
145-
def startswith(self, pat: str, na: Any = ...) -> Series[bool]: ...
146-
def endswith(self, pat: str, na: Any = ...) -> Series[bool]: ...
145+
def startswith(self, pat: str | tuple[str, ...], na: Any = ...) -> Series[bool]: ...
146+
def endswith(self, pat: str | tuple[str, ...], na: Any = ...) -> Series[bool]: ...
147147
def findall(self, pat: str, flags: int = ...) -> Series: ...
148148
@overload
149149
def extract(
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
def parse(version: str) -> LegacyVersion | Version: ...
2+
3+
class _BaseVersion:
4+
def __lt__(self, other: _BaseVersion) -> bool: ...
5+
def __le__(self, other: _BaseVersion) -> bool: ...
6+
def __eq__(self, other: object) -> bool: ...
7+
def __ge__(self, other: _BaseVersion) -> bool: ...
8+
def __gt__(self, other: _BaseVersion) -> bool: ...
9+
def __ne__(self, other: object) -> bool: ...
10+
11+
class LegacyVersion(_BaseVersion):
12+
def __init__(self, version: str) -> None: ...
13+
@property
14+
def public(self) -> str: ...
15+
@property
16+
def base_version(self) -> str: ...
17+
@property
18+
def epoch(self) -> int: ...
19+
@property
20+
def release(self) -> None: ...
21+
@property
22+
def pre(self) -> None: ...
23+
@property
24+
def post(self) -> None: ...
25+
@property
26+
def dev(self) -> None: ...
27+
@property
28+
def local(self) -> None: ...
29+
@property
30+
def is_prerelease(self) -> bool: ...
31+
@property
32+
def is_postrelease(self) -> bool: ...
33+
@property
34+
def is_devrelease(self) -> bool: ...
35+
36+
class Version(_BaseVersion):
37+
def __init__(self, version: str) -> None: ...
38+
@property
39+
def epoch(self) -> int: ...
40+
@property
41+
def release(self) -> tuple[int, ...]: ...
42+
@property
43+
def pre(self) -> tuple[str, int] | None: ...
44+
@property
45+
def post(self) -> int | None: ...
46+
@property
47+
def dev(self) -> int | None: ...
48+
@property
49+
def local(self) -> str | None: ...
50+
@property
51+
def public(self) -> str: ...
52+
@property
53+
def base_version(self) -> str: ...
54+
@property
55+
def is_prerelease(self) -> bool: ...
56+
@property
57+
def is_postrelease(self) -> bool: ...
58+
@property
59+
def is_devrelease(self) -> bool: ...
60+
@property
61+
def major(self) -> int: ...
62+
@property
63+
def minor(self) -> int: ...
64+
@property
65+
def micro(self) -> int: ...

0 commit comments

Comments
 (0)