Skip to content

Commit c07bab7

Browse files
Merge branch 'main' of github.com:loicdiridollou/pandas-stubs into stubtest_improv_p2
2 parents 2b64e3b + 845f9c5 commit c07bab7

File tree

17 files changed

+666
-15
lines changed

17 files changed

+666
-15
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ from pandas import (
3434
)
3535
from pandas.core.arrays import ExtensionArray
3636
from pandas.core.base import IndexOpsMixin
37-
from pandas.core.strings import StringMethods
37+
from pandas.core.strings.accessor import StringMethods
3838
from typing_extensions import (
3939
Never,
4040
Self,

pandas-stubs/core/indexes/multi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class MultiIndex(Index):
5757
@classmethod
5858
def from_product(
5959
cls,
60-
iterables: Sequence[SequenceNotStr[Hashable] | pd.Series | pd.Index],
60+
iterables: Sequence[SequenceNotStr[Hashable] | pd.Series | pd.Index | range],
6161
sortorder: int | None = ...,
6262
names: SequenceNotStr[Hashable] = ...,
6363
) -> Self: ...

pandas-stubs/core/series.pyi

Lines changed: 242 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ from typing import (
2525
Generic,
2626
Literal,
2727
NoReturn,
28+
TypeVar,
2829
final,
2930
overload,
3031
)
@@ -77,7 +78,7 @@ from pandas.core.indexing import (
7778
_IndexSliceTuple,
7879
_LocIndexer,
7980
)
80-
from pandas.core.strings import StringMethods
81+
from pandas.core.strings.accessor import StringMethods
8182
from pandas.core.window import (
8283
Expanding,
8384
ExponentialMovingWindow,
@@ -175,6 +176,8 @@ from pandas._typing import (
175176
VoidDtypeArg,
176177
WriteBuffer,
177178
np_ndarray_anyint,
179+
np_ndarray_complex,
180+
np_ndarray_float,
178181
npt,
179182
num,
180183
)
@@ -184,6 +187,8 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
184187

185188
from pandas.plotting import PlotAccessor
186189

190+
_T_COMPLEX = TypeVar("_T_COMPLEX", bound=complex)
191+
187192
class _iLocIndexerSeries(_iLocIndexer, Generic[S1]):
188193
# get item
189194
@overload
@@ -1617,12 +1622,48 @@ class Series(IndexOpsMixin[S1], NDFrame):
16171622
# just failed to generate these so I couldn't match
16181623
# them up.
16191624
@overload
1620-
def __add__(self, other: S1 | Self) -> Self: ...
1621-
@overload
16221625
def __add__(
1623-
self,
1624-
other: num | _str | timedelta | Timedelta | _ListLike | Series | np.timedelta64,
1626+
self: Series[Never],
1627+
other: Scalar | _ListLike | Series,
16251628
) -> Series: ...
1629+
@overload
1630+
def __add__(self, other: Series[Never]) -> Series: ...
1631+
@overload
1632+
def __add__(
1633+
self: Series[int], other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX]
1634+
) -> Series[_T_COMPLEX]: ...
1635+
@overload
1636+
def __add__(self: Series[int], other: np_ndarray_anyint) -> Series[int]: ...
1637+
@overload
1638+
def __add__(self: Series[int], other: np_ndarray_float) -> Series[float]: ...
1639+
@overload
1640+
def __add__(self: Series[int], other: np_ndarray_complex) -> Series[complex]: ...
1641+
@overload
1642+
def __add__(
1643+
self: Series[float],
1644+
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
1645+
) -> Series[float]: ...
1646+
@overload
1647+
def __add__(
1648+
self: Series[float],
1649+
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
1650+
) -> Series[_T_COMPLEX]: ...
1651+
@overload
1652+
def __add__(self: Series[float], other: np_ndarray_complex) -> Series[complex]: ...
1653+
@overload
1654+
def __add__(
1655+
self: Series[complex],
1656+
other: (
1657+
_T_COMPLEX
1658+
| Sequence[_T_COMPLEX]
1659+
| Series[_T_COMPLEX]
1660+
| np_ndarray_anyint
1661+
| np_ndarray_float
1662+
| np_ndarray_complex
1663+
),
1664+
) -> Series[complex]: ...
1665+
@overload
1666+
def __add__(self, other: S1 | Self) -> Self: ...
16261667
# ignore needed for mypy as we want different results based on the arguments
16271668
@overload # type: ignore[override]
16281669
def __and__( # pyright: ignore[reportOverlappingOverload]
@@ -1661,9 +1702,40 @@ class Series(IndexOpsMixin[S1], NDFrame):
16611702
@overload
16621703
def __or__(self, other: int | np_ndarray_anyint | Series[int]) -> Series[int]: ...
16631704
@overload
1664-
def __radd__(self, other: S1 | Series[S1]) -> Self: ...
1705+
def __radd__(self: Series[Never], other: Scalar | _ListLike) -> Series: ...
1706+
@overload
1707+
def __radd__(
1708+
self: Series[int], other: _T_COMPLEX | Sequence[_T_COMPLEX]
1709+
) -> Series[_T_COMPLEX]: ...
1710+
@overload
1711+
def __radd__(self: Series[int], other: np_ndarray_anyint) -> Series[int]: ...
1712+
@overload
1713+
def __radd__(self: Series[int], other: np_ndarray_float) -> Series[float]: ...
1714+
@overload
1715+
def __radd__(self: Series[int], other: np_ndarray_complex) -> Series[complex]: ...
1716+
@overload
1717+
def __radd__(
1718+
self: Series[float],
1719+
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float,
1720+
) -> Series[float]: ...
1721+
@overload
1722+
def __radd__(
1723+
self: Series[float], other: _T_COMPLEX | Sequence[_T_COMPLEX]
1724+
) -> Series[_T_COMPLEX]: ...
16651725
@overload
1666-
def __radd__(self, other: num | _str | _ListLike | Series) -> Series: ...
1726+
def __radd__(self: Series[float], other: np_ndarray_complex) -> Series[complex]: ...
1727+
@overload
1728+
def __radd__(
1729+
self: Series[complex],
1730+
other: (
1731+
np_ndarray_anyint
1732+
| np_ndarray_float
1733+
| np_ndarray_complex
1734+
| Sequence[_T_COMPLEX]
1735+
),
1736+
) -> Series[complex]: ...
1737+
@overload
1738+
def __radd__(self, other: S1) -> Self: ...
16671739
# ignore needed for mypy as we want different results based on the arguments
16681740
@overload # type: ignore[override]
16691741
def __rand__( # pyright: ignore[reportOverlappingOverload]
@@ -1738,13 +1810,92 @@ class Series(IndexOpsMixin[S1], NDFrame):
17381810
@property
17391811
def loc(self) -> _LocIndexerSeries[S1]: ...
17401812
# Methods
1813+
@overload
1814+
def add(
1815+
self: Series[Never],
1816+
other: Scalar | _ListLike | Series,
1817+
level: Level | None = ...,
1818+
fill_value: float | None = ...,
1819+
axis: int = ...,
1820+
) -> Series: ...
1821+
@overload
1822+
def add(
1823+
self: Series[int],
1824+
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
1825+
level: Level | None = ...,
1826+
fill_value: float | None = ...,
1827+
axis: int = ...,
1828+
) -> Series[_T_COMPLEX]: ...
1829+
@overload
1830+
def add(
1831+
self: Series[int],
1832+
other: np_ndarray_anyint,
1833+
level: Level | None = ...,
1834+
fill_value: float | None = ...,
1835+
axis: int = ...,
1836+
) -> Series[int]: ...
1837+
@overload
1838+
def add(
1839+
self: Series[int],
1840+
other: np_ndarray_float,
1841+
level: Level | None = ...,
1842+
fill_value: float | None = ...,
1843+
axis: int = ...,
1844+
) -> Series[float]: ...
1845+
@overload
1846+
def add(
1847+
self: Series[int],
1848+
other: np_ndarray_complex,
1849+
level: Level | None = ...,
1850+
fill_value: float | None = ...,
1851+
axis: int = ...,
1852+
) -> Series[complex]: ...
1853+
@overload
1854+
def add(
1855+
self: Series[float],
1856+
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
1857+
level: Level | None = ...,
1858+
fill_value: float | None = ...,
1859+
axis: int = ...,
1860+
) -> Series[float]: ...
1861+
@overload
1862+
def add(
1863+
self: Series[float],
1864+
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
1865+
level: Level | None = ...,
1866+
fill_value: float | None = ...,
1867+
axis: int = ...,
1868+
) -> Series[_T_COMPLEX]: ...
1869+
@overload
1870+
def add(
1871+
self: Series[float],
1872+
other: np_ndarray_complex,
1873+
level: Level | None = ...,
1874+
fill_value: float | None = ...,
1875+
axis: int = ...,
1876+
) -> Series[complex]: ...
1877+
@overload
1878+
def add(
1879+
self: Series[complex],
1880+
other: (
1881+
Sequence[_T_COMPLEX]
1882+
| np_ndarray_anyint
1883+
| np_ndarray_float
1884+
| np_ndarray_complex
1885+
| Series[_T_COMPLEX]
1886+
),
1887+
level: Level | None = ...,
1888+
fill_value: float | None = ...,
1889+
axis: int = ...,
1890+
) -> Series[complex]: ...
1891+
@overload
17411892
def add(
17421893
self,
1743-
other: Series[S1] | Scalar,
1894+
other: S1 | Series[S1],
17441895
level: Level | None = ...,
17451896
fill_value: float | None = ...,
17461897
axis: int = ...,
1747-
) -> Series[S1]: ...
1898+
) -> Self: ...
17481899
def all(
17491900
self,
17501901
axis: AxisIndex = ...,
@@ -1984,13 +2135,92 @@ class Series(IndexOpsMixin[S1], NDFrame):
19842135
min_count: int = ...,
19852136
**kwargs: Any,
19862137
) -> Scalar: ...
2138+
@overload
2139+
def radd(
2140+
self: Series[Never],
2141+
other: Scalar | _ListLike | Series,
2142+
level: Level | None = ...,
2143+
fill_value: float | None = ...,
2144+
axis: AxisIndex = ...,
2145+
) -> Series: ...
2146+
@overload
2147+
def radd(
2148+
self: Series[int],
2149+
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
2150+
level: Level | None = ...,
2151+
fill_value: float | None = ...,
2152+
axis: int = ...,
2153+
) -> Series[_T_COMPLEX]: ...
2154+
@overload
2155+
def radd(
2156+
self: Series[int],
2157+
other: np_ndarray_anyint,
2158+
level: Level | None = ...,
2159+
fill_value: float | None = ...,
2160+
axis: int = ...,
2161+
) -> Series[int]: ...
2162+
@overload
2163+
def radd(
2164+
self: Series[int],
2165+
other: np_ndarray_float,
2166+
level: Level | None = ...,
2167+
fill_value: float | None = ...,
2168+
axis: int = ...,
2169+
) -> Series[float]: ...
2170+
@overload
2171+
def radd(
2172+
self: Series[int],
2173+
other: np_ndarray_complex,
2174+
level: Level | None = ...,
2175+
fill_value: float | None = ...,
2176+
axis: int = ...,
2177+
) -> Series[complex]: ...
2178+
@overload
2179+
def radd(
2180+
self: Series[float],
2181+
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int],
2182+
level: Level | None = ...,
2183+
fill_value: float | None = ...,
2184+
axis: int = ...,
2185+
) -> Series[float]: ...
2186+
@overload
2187+
def radd(
2188+
self: Series[float],
2189+
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX],
2190+
level: Level | None = ...,
2191+
fill_value: float | None = ...,
2192+
axis: int = ...,
2193+
) -> Series[_T_COMPLEX]: ...
2194+
@overload
2195+
def radd(
2196+
self: Series[float],
2197+
other: np_ndarray_complex,
2198+
level: Level | None = ...,
2199+
fill_value: float | None = ...,
2200+
axis: int = ...,
2201+
) -> Series[complex]: ...
2202+
@overload
2203+
def radd(
2204+
self: Series[complex],
2205+
other: (
2206+
Sequence[_T_COMPLEX]
2207+
| np_ndarray_anyint
2208+
| np_ndarray_float
2209+
| np_ndarray_complex
2210+
| Series[_T_COMPLEX]
2211+
),
2212+
level: Level | None = ...,
2213+
fill_value: float | None = ...,
2214+
axis: int = ...,
2215+
) -> Series[complex]: ...
2216+
@overload
19872217
def radd(
19882218
self,
1989-
other: Series[S1] | Scalar,
2219+
other: S1 | Series[S1],
19902220
level: Level | None = ...,
19912221
fill_value: float | None = ...,
19922222
axis: AxisIndex = ...,
1993-
) -> Series[S1]: ...
2223+
) -> Self: ...
19942224
def rdivmod(
19952225
self,
19962226
other: Series[S1] | Scalar,
@@ -2394,7 +2624,7 @@ class PeriodSeries(Series[Period]):
23942624
) -> Never: ...
23952625

23962626
class OffsetSeries(Series[BaseOffset]):
2397-
@overload # type: ignore[override]
2627+
@overload
23982628
def __radd__(self, other: Period) -> PeriodSeries: ...
23992629
@overload
24002630
def __radd__( # pyright: ignore[reportIncompatibleMethodOverride]

pandas-stubs/core/strings/__init__.pyi

Whitespace-only changes.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mypy = "1.17.0"
3939
pandas = "2.3.1"
4040
pyarrow = ">=10.0.1"
4141
pytest = ">=7.1.2"
42-
pyright = ">=1.1.400"
42+
pyright = ">=1.1.403"
4343
ty = "^0.0.1a8"
4444
pyrefly = "^0.21.0"
4545
poethepoet = ">=0.16.5"

tests/series/__init__.py

Whitespace-only changes.

tests/series/arithmetic/__init__.py

Whitespace-only changes.

tests/series/arithmetic/complex/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)