Skip to content

Commit 0015e53

Browse files
committed
more tests
1 parent 6dc0ea9 commit 0015e53

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
524524
self, start: SliceType = None, end: SliceType = None, step: int | None = None
525525
): ...
526526
def delete(self, loc: int | AnyArrayLikeInt | Sequence[int]) -> Self: ...
527-
def insert(self, loc: int, item: S1) -> Self: ...
527+
def insert(self, loc: int, item: object) -> Index: ...
528528
def drop(self, labels, errors: IgnoreRaise = "raise") -> Self: ...
529529
@property
530530
def shape(self) -> tuple[int, ...]: ...

tests/indexes/test_categoricalindex.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ def test_categoricalindex_reindex() -> None:
2525
reindexed = ci.reindex(["b", "c"])
2626
check(assert_type(reindexed[0], pd.Index), pd.Index)
2727
check(assert_type(reindexed[1], np_1darray[np.intp] | None), np_1darray)
28+
29+
30+
def test_categoricalindex_delete() -> None:
31+
ci = pd.CategoricalIndex(["a", "b"])
32+
check(assert_type(ci.delete(0), "pd.CategoricalIndex[str]"), pd.CategoricalIndex)
33+
check(
34+
assert_type(ci.delete([0, 1]), "pd.CategoricalIndex[str]"), pd.CategoricalIndex
35+
)
36+
37+
38+
def test_categoricalindex_insert() -> None:
39+
ci = pd.CategoricalIndex(["a", "b"])
40+
check(assert_type(ci.insert(0, "c"), pd.Index), pd.Index)

0 commit comments

Comments
 (0)