Skip to content

Commit 0a841c7

Browse files
committed
fix: comment
1 parent dd489f8 commit 0a841c7

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

tests/indexes/test_indexes.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,8 +1524,15 @@ def test_period_index_asof_locs() -> None:
15241524

15251525
def test_array_property() -> None:
15261526
"""Test that Index.array and semantic Index.array return ExtensionArray and its subclasses"""
1527-
# pandas-dev/pandas-stubs#1383
1528-
# check(assert_type(Index([1], dtype="category").array, pd.Categorical), pd.Categorical, np.int64)
1527+
# casting due to pandas-dev/pandas-stubs#1383
1528+
check(
1529+
assert_type(
1530+
cast("Index[pd.CategoricalDtype]", Index([1], dtype="category")).array,
1531+
pd.Categorical,
1532+
),
1533+
pd.Categorical,
1534+
np.int64,
1535+
)
15291536
check(
15301537
assert_type(pd.interval_range(0, 1).array, IntervalArray),
15311538
IntervalArray,

tests/series/test_properties.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import (
22
TYPE_CHECKING,
3+
cast,
34
)
45

56
import numpy as np
@@ -53,8 +54,17 @@ def test_dt_property() -> None:
5354

5455
def test_array_property() -> None:
5556
"""Test that Series.array returns ExtensionArray and its subclasses"""
56-
# pandas-dev/pandas-stubs#1383
57-
# check(assert_type(pd.Series([1], dtype="category").array, pd.Categorical), pd.Categorical, np.int64)
57+
# casting due to pandas-dev/pandas-stubs#1383
58+
check(
59+
assert_type(
60+
cast(
61+
"pd.Series[pd.CategoricalDtype]", pd.Series([1], dtype="category")
62+
).array,
63+
pd.Categorical,
64+
),
65+
pd.Categorical,
66+
np.int64,
67+
)
5868
check(
5969
assert_type(pd.Series(pd.interval_range(0, 1)).array, IntervalArray),
6070
IntervalArray,

tests/series/test_series.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
TypedDict,
2222
TypeVar,
2323
Union,
24+
cast,
2425
)
2526

2627
import numpy as np
@@ -3514,21 +3515,19 @@ def test_diff() -> None:
35143515
index_to_check_for_type=-1,
35153516
)
35163517
# nullable bool -> nullable bool
3517-
with pytest_warns_bounded(
3518-
UserWarning,
3519-
r"Instantiating BooleanDtype without any arguments.Pass a BooleanDtype instance to silence this warning.",
3520-
):
3521-
check(
3522-
assert_type(
3523-
pd.Series(
3524-
[True, True, False, False, True], dtype=pd.BooleanDtype
3525-
).diff(),
3518+
# casting due to pandas-dev/pandas-stubs#1395
3519+
check(
3520+
assert_type(
3521+
cast(
35263522
"pd.Series[pd.BooleanDtype]",
3523+
pd.Series([True, True, False, False, True], dtype="boolean").diff(),
35273524
),
3528-
pd.Series,
3529-
np.bool_,
3530-
index_to_check_for_type=-1,
3531-
)
3525+
"pd.Series[pd.BooleanDtype]",
3526+
),
3527+
pd.Series,
3528+
np.bool_,
3529+
index_to_check_for_type=-1,
3530+
)
35323531
# Any -> float
35333532
s_o = s.astype(object)
35343533
assert_type(s_o, "pd.Series[Any]")

0 commit comments

Comments
 (0)