Skip to content

Commit d7a538d

Browse files
committed
fix(comment): avoid union types #1282 (comment)
1 parent fa3c401 commit d7a538d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ from typing_extensions import (
4343
from pandas._libs.interval import _OrderableT
4444
from pandas._typing import (
4545
S1,
46-
S2,
4746
AnyAll,
4847
AxesData,
4948
DropKeep,
@@ -405,9 +404,7 @@ class Index(IndexOpsMixin[S1]):
405404
@overload
406405
def append(self, other: Index[S1] | Sequence[Index[S1]]) -> Self: ...
407406
@overload
408-
def append(self, other: Index[S2]) -> Index[S1 | S2]: ...
409-
@overload
410-
def append(self, other: Sequence[Index]) -> Index: ...
407+
def append(self, other: Index | Sequence[Index]) -> Index: ...
411408
def putmask(self, mask, value): ...
412409
def equals(self, other) -> bool: ...
413410
@final

tests/test_indexes.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,19 +1031,14 @@ def test_getitem() -> None:
10311031

10321032

10331033
def test_append_mix() -> None:
1034-
"""Test pd.Index.append that gives pd.Index[Any]"""
1034+
"""Test pd.Index.append with mixed types"""
10351035
first = pd.Index([1])
10361036
second = pd.Index(["a"])
10371037
third = pd.Index([1, "a"])
1038-
check(assert_type(first.append(second), "pd.Index[int | str]"), pd.Index)
1038+
check(assert_type(first.append(second), pd.Index), pd.Index)
10391039
check(assert_type(first.append([second]), pd.Index), pd.Index)
10401040

1041-
check(
1042-
assert_type( # type: ignore[assert-type]
1043-
first.append(third), "pd.Index[int | str]"
1044-
),
1045-
pd.Index,
1046-
)
1041+
check(assert_type(first.append(third), pd.Index), pd.Index)
10471042
check(assert_type(first.append([third]), pd.Index), pd.Index)
10481043
check(assert_type(first.append([second, third]), pd.Index), pd.Index)
10491044

0 commit comments

Comments
 (0)