Skip to content

Commit 3607e75

Browse files
combine the overloads
1 parent babc396 commit 3607e75

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pandas/core/algorithms.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from typing import (
1212
TYPE_CHECKING,
1313
Literal,
14+
TypeVar,
1415
cast,
1516
overload,
1617
)
@@ -105,6 +106,8 @@
105106
ExtensionArray,
106107
)
107108

109+
T = TypeVar("T", bound=Index | Categorical | ExtensionArray)
110+
108111

109112
# --------------- #
110113
# dtype access #
@@ -316,15 +319,9 @@ def _check_object_for_strings(values: np.ndarray) -> str:
316319

317320

318321
@overload
319-
def unique(values: np.ndarray) -> np.ndarray: ...
320-
@overload
321-
def unique(values: Index) -> Index: ...
322-
@overload
323-
def unique(values: Series) -> np.ndarray: ...
324-
@overload
325-
def unique(values: Categorical) -> Categorical: ...
322+
def unique(values: T) -> T: ...
326323
@overload
327-
def unique(values: ExtensionArray) -> ExtensionArray: ...
324+
def unique(values: np.ndarray | Series) -> np.ndarray: ...
328325

329326

330327
def unique(values):

0 commit comments

Comments
 (0)