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: 2 additions & 1 deletion pandas-stubs/core/dtypes/common.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Union

import pandas as pd
from pandas.api.extensions import ExtensionDtype
from typing_extensions import TypeAlias

from pandas._typing import (
Expand Down Expand Up @@ -29,7 +30,7 @@ from pandas.core.dtypes.inference import (
)

_ArrayOrDtype: TypeAlias = Union[
ArrayLike, npt.DTypeLike, pd.Series, pd.DataFrame, pd.Index
ArrayLike, npt.DTypeLike, pd.Series, pd.DataFrame, pd.Index, ExtensionDtype
]

def is_object_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
Expand Down
30 changes: 25 additions & 5 deletions tests/test_api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_is_bool_dtype() -> None:
bool,
)
check(assert_type(api.is_bool_dtype(ind), bool), bool)
check(assert_type(api.is_bool_dtype(ExtensionDtype), bool), bool)


def test_is_categorical_dtype() -> None:
Expand All @@ -59,6 +60,7 @@ def test_is_categorical_dtype() -> None:
bool,
)
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)


def test_is_complex() -> None:
Expand All @@ -82,6 +84,7 @@ def test_is_complex_dtype() -> None:
bool,
)
check(assert_type(api.is_complex_dtype(ind), bool), bool)
# check(assert_type(api.is_complex_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_datetime64_any_dtype() -> None:
Expand All @@ -93,6 +96,7 @@ def test_is_datetime64_any_dtype() -> None:
bool,
)
check(assert_type(api.is_datetime64_any_dtype(ind), bool), bool)
# check(assert_type(api.is_datetime64_any_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_datetime64_dtype() -> None:
Expand All @@ -104,6 +108,7 @@ def test_is_datetime64_dtype() -> None:
bool,
)
check(assert_type(api.is_datetime64_dtype(ind), bool), bool)
# check(assert_type(api.is_datetime64_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_datetime64_ns_dtype() -> None:
Expand All @@ -115,6 +120,7 @@ def test_is_datetime64_ns_dtype() -> None:
bool,
)
check(assert_type(api.is_datetime64_ns_dtype(ind), bool), bool)
check(assert_type(api.is_datetime64_ns_dtype(ExtensionDtype), bool), bool)


def test_is_datetime64tz_dtype() -> None:
Expand All @@ -126,6 +132,7 @@ def test_is_datetime64tz_dtype() -> None:
bool,
)
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)


def test_is_dict_like() -> None:
Expand Down Expand Up @@ -153,6 +160,7 @@ def test_is_extension_array_dtype() -> None:
bool,
)
check(assert_type(api.is_extension_array_dtype(ind), bool), bool)
check(assert_type(api.is_extension_array_dtype(ExtensionDtype), bool), bool)


def test_is_file_like() -> None:
Expand Down Expand Up @@ -185,6 +193,7 @@ def test_is_float_dtype() -> None:
bool,
)
check(assert_type(api.is_float_dtype(ind), bool), bool)
# check(assert_type(api.is_float_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_hashable() -> None:
Expand All @@ -208,6 +217,7 @@ def test_is_int64_dtype() -> None:
bool,
)
check(assert_type(api.is_int64_dtype(ind), bool), bool)
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_integer() -> None:
Expand All @@ -231,6 +241,7 @@ def test_is_integer_dtype() -> None:
bool,
)
check(assert_type(api.is_integer_dtype(ind), bool), bool)
# check(assert_type(api.is_integer_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_interval() -> None:
Expand All @@ -247,14 +258,15 @@ def test_is_interval() -> None:

def test_is_interval_dtype() -> None:
check(assert_type(api.is_interval_dtype(obj), bool), bool)
check(assert_type(api.is_interval(nparr), bool), bool)
check(assert_type(api.is_interval(dtylike), bool), bool)
check(assert_type(api.is_interval(arr), bool), bool)
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
check(assert_type(api.is_interval_dtype(arr), bool), bool)
check(
assert_type(api.is_interval(dframe), bool),
assert_type(api.is_interval_dtype(dframe), bool),
bool,
)
check(assert_type(api.is_interval(ind), bool), bool)
check(assert_type(api.is_interval_dtype(ind), bool), bool)
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)


def test_is_iterator() -> None:
Expand Down Expand Up @@ -311,6 +323,7 @@ def test_is_numeric_dtype() -> None:
bool,
)
check(assert_type(api.is_numeric_dtype(ind), bool), bool)
# check(assert_type(api.is_numeric_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_object_dtype() -> None:
Expand All @@ -322,6 +335,7 @@ def test_is_object_dtype() -> None:
bool,
)
check(assert_type(api.is_object_dtype(ind), bool), bool)
# check(assert_type(api.is_object_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_period_dtype() -> None:
Expand All @@ -333,6 +347,7 @@ def test_is_period_dtype() -> None:
bool,
)
check(assert_type(api.is_period_dtype(ind), bool), bool)
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)


def test_is_re() -> None:
Expand Down Expand Up @@ -374,6 +389,7 @@ def test_is_signed_integer_dtype() -> None:
bool,
)
check(assert_type(api.is_signed_integer_dtype(ind), bool), bool)
# check(assert_type(api.is_signed_integer_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_sparse() -> None:
Expand All @@ -391,6 +407,7 @@ def test_is_string_dtype() -> None:
bool,
)
check(assert_type(api.is_string_dtype(ind), bool), bool)
check(assert_type(api.is_string_dtype(ExtensionDtype), bool), bool)


def test_is_timedelta64_dtype() -> None:
Expand All @@ -402,6 +419,7 @@ def test_is_timedelta64_dtype() -> None:
bool,
)
check(assert_type(api.is_timedelta64_dtype(ind), bool), bool)
# check(assert_type(api.is_timedelta64_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_is_timedelta64_ns_dtype() -> None:
Expand All @@ -413,6 +431,7 @@ def test_is_timedelta64_ns_dtype() -> None:
bool,
)
check(assert_type(api.is_timedelta64_ns_dtype(ind), bool), bool)
check(assert_type(api.is_timedelta64_ns_dtype(ExtensionDtype), bool), bool)


def test_is_unsigned_integer_dtype() -> None:
Expand All @@ -427,6 +446,7 @@ def test_is_unsigned_integer_dtype() -> None:
bool,
)
check(assert_type(api.is_unsigned_integer_dtype(ind), bool), bool)
# check(assert_type(api.is_unsigned_integer_dtype(ExtensionDtype), bool), bool) pandas GH 50923


def test_pandas_dtype() -> None:
Expand Down