Skip to content

Commit 427a707

Browse files
committed
add test to cover passing UnknownSeries to cat
1 parent 0fabb99 commit 427a707

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pandas-stubs/_typing.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,6 @@ S2 = TypeVar(
576576
| list[str],
577577
)
578578

579-
UnknownSeries: TypeAlias = Series[Any]
580-
UnknownIndex: TypeAlias = Index[Any]
581-
582579
IndexingInt: TypeAlias = (
583580
int | np.int_ | np.integer | np.unsignedinteger | np.signedinteger | np.int8
584581
)

pandas-stubs/core/indexes/base.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from typing import (
1313
Any,
1414
ClassVar,
1515
Literal,
16+
TypeAlias,
1617
final,
1718
overload,
1819
)
@@ -455,7 +456,7 @@ class Index(IndexOpsMixin[S1]):
455456
),
456457
) -> Self: ...
457458

458-
class UnknownIndex(Index[Any]): ...
459+
UnknownIndex: TypeAlias = Index[Any]
459460

460461
def ensure_index_from_sequences(
461462
sequences: Sequence[Sequence[Dtype]], names: list[str] = ...

pandas-stubs/core/series.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -2295,3 +2295,5 @@ class IntervalSeries(Series[Interval[_OrderableT]], Generic[_OrderableT]):
22952295
@property
22962296
def array(self) -> IntervalArray: ...
22972297
def diff(self, periods: int = ...) -> Never: ...
2298+
2299+
UnknownSeries: TypeAlias = Series[Any]

tests/test_series.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@
6565
OffsetSeries,
6666
TimedeltaSeries,
6767
TimestampSeries,
68+
UnknownSeries,
6869
)
69-
70-
from pandas._typing import UnknownSeries
7170
else:
7271
TimedeltaSeries: TypeAlias = pd.Series
7372
TimestampSeries: TypeAlias = pd.Series
@@ -1681,6 +1680,11 @@ def test_series_overloads_cat():
16811680
),
16821681
UnknownSeries,
16831682
)
1683+
unknown_s: UnknownSeries = pd.DataFrame({"a": ["a", "b"]})["a"]
1684+
check(
1685+
assert_type(s.str.cat(unknown_s, sep=";"), UnknownSeries),
1686+
UnknownSeries,
1687+
)
16841688

16851689

16861690
def test_series_overloads_partition():

0 commit comments

Comments
 (0)