Skip to content

Commit 67e6bde

Browse files
committed
fix(comment): #1282 (comment)
1 parent ac0857b commit 67e6bde

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ from typing import (
1515
ClassVar,
1616
Literal,
1717
TypeAlias,
18-
TypeVar,
1918
final,
2019
overload,
2120
)
@@ -66,8 +65,6 @@ from pandas._typing import (
6665
type_t,
6766
)
6867

69-
_T_INDEX = TypeVar("_T_INDEX", bound=Index) # ty: ignore[unresolved-reference]
70-
7168
class InvalidIndexError(Exception): ...
7269

7370
class Index(IndexOpsMixin[S1]):
@@ -408,11 +405,9 @@ class Index(IndexOpsMixin[S1]):
408405
@overload
409406
def append(self, other: Index[S1] | Sequence[Index[S1]]) -> Self: ...
410407
@overload
411-
def append(self, other: Index[S2] | Sequence[Index[S2]]) -> Index[S1 | S2]: ...
412-
@overload
413-
def append(self, other: Sequence[_T_INDEX]) -> Self | _T_INDEX: ...
408+
def append(self, other: Index[S2]) -> Index[S1 | S2]: ...
414409
@overload
415-
def append(self, other: Index | Sequence) -> Index: ...
410+
def append(self, other: Sequence) -> Index: ...
416411
def putmask(self, mask, value): ...
417412
def equals(self, other) -> bool: ...
418413
@final

tests/test_indexes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,31 +1036,31 @@ def test_append_mix() -> None:
10361036
second = pd.Index(["a"])
10371037
third = pd.Index([1, "a"])
10381038
check(assert_type(first.append(second), "pd.Index[int | str]"), pd.Index)
1039-
check(assert_type(first.append([second]), "pd.Index[int | str]"), pd.Index)
1039+
check(assert_type(first.append([second]), pd.Index), pd.Index)
10401040

1041-
check(assert_type(first.append(third), "pd.Index[int | str]"), pd.Index) # type: ignore[assert-type]
1042-
check(assert_type(first.append([third]), "pd.Index[int | str]"), pd.Index) # type: ignore[assert-type]
10431041
check(
10441042
assert_type( # type: ignore[assert-type]
1045-
first.append([second, third]), # pyright: ignore[reportAssertTypeFailure]
1046-
"pd.Index[int | str]",
1043+
first.append(third), "pd.Index[int | str]"
10471044
),
10481045
pd.Index,
10491046
)
1047+
check(assert_type(first.append([third]), pd.Index), pd.Index)
1048+
check(assert_type(first.append([second, third]), pd.Index), pd.Index)
10501049

1051-
check(assert_type(third.append([]), "pd.Index[int | str]"), pd.Index) # type: ignore[assert-type]
10521050
check(
1053-
assert_type(third.append(cast("list[Index[Any]]", [])), "pd.Index[int | str]"), # type: ignore[assert-type]
1051+
assert_type( # type: ignore[assert-type]
1052+
third.append([]), "pd.Index[int | str]"
1053+
),
10541054
pd.Index,
10551055
)
1056-
check(assert_type(third.append([first]), "pd.Index[int | str]"), pd.Index) # type: ignore[assert-type]
10571056
check(
10581057
assert_type( # type: ignore[assert-type]
1059-
third.append([first, second]), # pyright: ignore[reportAssertTypeFailure]
1060-
"pd.Index[int | str]",
1058+
third.append(cast("list[Index[Any]]", [])), "pd.Index[int | str]"
10611059
),
10621060
pd.Index,
10631061
)
1062+
check(assert_type(third.append([first]), pd.Index), pd.Index)
1063+
check(assert_type(third.append([first, second]), pd.Index), pd.Index)
10641064

10651065

10661066
def test_append_int() -> None:

0 commit comments

Comments
 (0)