Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas-stubs/core/indexes/category.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from typing import final

import numpy as np
from pandas.core import accessor
from pandas.core.arrays.categorical import Categorical
from pandas.core.indexes.base import Index
from pandas.core.indexes.extension import ExtensionIndex
from typing_extensions import Self
Expand All @@ -18,6 +19,8 @@ from pandas._typing import (
class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
codes: np.ndarray = ...
categories: Index = ...
@property
def array(self) -> Categorical: ... # type: ignore[override] # pyrefly: ignore[bad-override]
def __new__(
cls,
data: Iterable[S1] = ...,
Expand Down
5 changes: 1 addition & 4 deletions tests/indexes/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,10 +1531,7 @@ def test_array_property() -> None:
"""Test that Index.array and semantic Index.array return ExtensionArray and its subclasses"""
# casting due to pandas-dev/pandas-stubs#1383
check(
assert_type(
cast("Index[pd.CategoricalDtype]", Index([1], dtype="category")).array,
pd.Categorical,
),
assert_type(Index([1], dtype="category").array, pd.Categorical),
pd.Categorical,
int,
)
Expand Down