Skip to content

Commit b71d4cb

Browse files
committed
comments
1 parent 88b32e0 commit b71d4cb

File tree

10 files changed

+69
-75
lines changed

10 files changed

+69
-75
lines changed

pandas-stubs/_typing.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,11 +871,11 @@ DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
871871
KeysArgType: TypeAlias = Any
872872
ListLikeT = TypeVar("ListLikeT", bound=ListLike)
873873
ListLikeExceptSeriesAndStr: TypeAlias = (
874-
MutableSequence[Any] | np_1darray[Any] | tuple[Any, ...] | Index
874+
MutableSequence[Any] | np_1darray | tuple[Any, ...] | Index
875875
)
876-
ListLikeU: TypeAlias = Sequence | np_1darray[Any] | Series | Index
876+
ListLikeU: TypeAlias = Sequence | np_1darray | Series | Index
877877
ListLikeHashable: TypeAlias = (
878-
MutableSequence[HashableT] | np_1darray[Any] | tuple[HashableT, ...] | range
878+
MutableSequence[HashableT] | np_1darray | tuple[HashableT, ...] | range
879879
)
880880

881881
class SupportsDType(Protocol[GenericT_co]):

pandas-stubs/core/algorithms.pyi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from pandas._typing import (
2222
IntervalT,
2323
TakeIndexer,
2424
np_1darray,
25+
np_1darray_int64,
2526
np_ndarray,
2627
)
2728

@@ -36,19 +37,19 @@ def unique(values: PeriodIndex) -> PeriodIndex: ...
3637
@overload
3738
def unique(values: DatetimeIndex) -> np_1darray[np.datetime64] | DatetimeIndex: ...
3839
@overload
39-
def unique(values: Index) -> np_1darray[Any] | Index: ...
40+
def unique(values: Index) -> np_1darray | Index: ...
4041
@overload
4142
def unique(values: Categorical) -> Categorical: ...
4243

4344
# @overload
44-
# def unique(values: Series[Never]) -> np_1darray[Any] | ExtensionArray: ...
45+
# def unique(values: Series[Never]) -> np_1darray | ExtensionArray: ...
4546
# TODO: DatetimeArray python/mypy#19952
4647
# @overload
4748
# def unique(values: Series[Timestamp]) -> np_1darray[np.datetime64] | ExtensionArray: ...
4849
# @overload
4950
# def unique(values: Series[int]) -> np_1darray[np.integer] | ExtensionArray: ...
5051
@overload
51-
def unique(values: Series) -> np_1darray[Any] | ExtensionArray: ...
52+
def unique(values: Series) -> np_1darray | ExtensionArray: ...
5253
@overload
5354
def unique(values: npt.NDArray[GenericT]) -> np_1darray[GenericT]: ...
5455
@overload
@@ -59,21 +60,21 @@ def factorize(
5960
sort: bool = ...,
6061
use_na_sentinel: bool = ...,
6162
size_hint: int | None = ...,
62-
) -> tuple[np_1darray[np.int64], np_1darray[GenericT]]: ...
63+
) -> tuple[np_1darray_int64, np_1darray[GenericT]]: ...
6364
@overload
6465
def factorize(
6566
values: Index | Series,
6667
sort: bool = ...,
6768
use_na_sentinel: bool = ...,
6869
size_hint: int | None = ...,
69-
) -> tuple[np_1darray[np.int64], Index]: ...
70+
) -> tuple[np_1darray_int64, Index]: ...
7071
@overload
7172
def factorize(
7273
values: Categorical,
7374
sort: bool = ...,
7475
use_na_sentinel: bool = ...,
7576
size_hint: int | None = ...,
76-
) -> tuple[np_1darray[np.int64], Categorical]: ...
77+
) -> tuple[np_1darray_int64, Categorical]: ...
7778
def value_counts(
7879
values: AnyArrayLike | list | tuple,
7980
sort: bool = True,
@@ -88,4 +89,4 @@ def take(
8889
axis: Literal[0, 1] = 0,
8990
allow_fill: bool = False,
9091
fill_value: Any = None,
91-
) -> np_1darray[Any] | ExtensionArray: ...
92+
) -> np_1darray | ExtensionArray: ...

pandas-stubs/core/arrays/base.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ExtensionArray:
4444
dtype: npt.DTypeLike | None = ...,
4545
copy: bool = False,
4646
na_value: Scalar = ...,
47-
) -> np_1darray[Any]: ...
47+
) -> np_1darray: ...
4848
@property
4949
def dtype(self) -> ExtensionDtype: ...
5050
@property
@@ -83,9 +83,7 @@ class ExtensionArray:
8383
side: Literal["left", "right"] = ...,
8484
sorter: ListLike | None = ...,
8585
) -> np.intp: ...
86-
def factorize(
87-
self, use_na_sentinel: bool = True
88-
) -> tuple[np_1darray[Any], Self]: ...
86+
def factorize(self, use_na_sentinel: bool = True) -> tuple[np_1darray, Self]: ...
8987
def repeat(
9088
self, repeats: int | AnyArrayLikeInt | Sequence[int], axis: None = None
9189
) -> Self: ...

pandas-stubs/core/arrays/masked.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class BaseMaskedArray(ExtensionArray, ExtensionOpsMixin):
3030
dtype: npt.DTypeLike | None = ...,
3131
copy: bool = False,
3232
na_value: Scalar = ...,
33-
) -> np_1darray[Any]: ...
33+
) -> np_1darray: ...
3434
__array_priority__: int = ...
3535
def __array__(
3636
self, dtype: NpDtype | None = None, copy: bool | None = None

pandas-stubs/core/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
156156
def is_monotonic_increasing(self) -> bool: ...
157157
def factorize(
158158
self, sort: bool = False, use_na_sentinel: bool = True
159-
) -> tuple[np_1darray[Any], np_1darray | Index | Categorical]: ...
159+
) -> tuple[np_1darray, np_1darray | Index | Categorical]: ...
160160
@overload
161161
def searchsorted(
162162
self,

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
483483
sort: bool = False,
484484
) -> Index: ...
485485
@property
486-
def values(self) -> np_1darray[Any]: ...
486+
def values(self) -> np_1darray: ...
487487
def memory_usage(self, deep: bool = False): ...
488488
@overload
489489
def where(

pandas-stubs/core/series.pyi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ from pandas._typing import (
219219
WriteBuffer,
220220
_T_co,
221221
np_1darray,
222+
np_1darray_int64,
222223
np_ndarray,
223224
np_ndarray_anyint,
224225
np_ndarray_bool,
@@ -535,8 +536,8 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
535536
@name.setter
536537
def name(self, value: Hashable | None) -> None: ...
537538
@property
538-
def values(self) -> np_1darray[Any] | ExtensionArray | Categorical: ...
539-
def ravel(self, order: _str = ...) -> np_1darray[Any]: ...
539+
def values(self) -> np_1darray | ExtensionArray | Categorical: ...
540+
def ravel(self, order: _str = ...) -> np_1darray: ...
540541
def __len__(self) -> int: ...
541542
def view(self, dtype: Dtype | None = None) -> Series[S1]: ...
542543
@final
@@ -876,13 +877,13 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
876877
def count(self) -> int: ...
877878
def mode(self, dropna: bool = True) -> Series[S1]: ...
878879
@overload
879-
def unique(self: Series[Never]) -> np_1darray[Any]: ... # type: ignore[overload-overlap]
880+
def unique(self: Series[Never]) -> np_1darray: ... # type: ignore[overload-overlap]
880881
@overload
881882
def unique(self: Series[Timestamp]) -> DatetimeArray: ... # type: ignore[overload-overlap]
882883
@overload
883884
def unique(self: Series[Timedelta]) -> TimedeltaArray: ... # type: ignore[overload-overlap]
884885
@overload
885-
def unique(self) -> np_1darray[Any]: ...
886+
def unique(self) -> np_1darray: ...
886887
@overload
887888
def drop_duplicates(
888889
self,
@@ -4463,7 +4464,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
44634464
copy: bool = False,
44644465
na_value: Scalar = ...,
44654466
**kwargs: Any,
4466-
) -> np_1darray[np.int64]: ...
4467+
) -> np_1darray_int64: ...
44674468
@overload
44684469
def to_numpy(
44694470
self: Series[BaseOffset],

tests/series/test_series.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def test_types_value_counts() -> None:
773773

774774
def test_types_unique() -> None:
775775
s = pd.Series([-10, 2, 2, 3, 10, 10])
776-
check(assert_type(s.unique(), np_1darray[Any]), np_1darray[Any])
776+
check(assert_type(s.unique(), np_1darray), np_1darray)
777777

778778

779779
def test_types_apply() -> None:
@@ -1414,36 +1414,36 @@ def test_types_values() -> None:
14141414
check(
14151415
assert_type(
14161416
pd.Series([1, 2, 3]).values,
1417-
np_1darray[Any] | ExtensionArray | pd.Categorical,
1417+
np_1darray | ExtensionArray | pd.Categorical,
14181418
),
14191419
np_1darray,
14201420
np.integer,
14211421
)
1422-
valresult_type: type[np_1darray[Any] | ExtensionArray | pd.Categorical]
1422+
valresult_type: type[np_1darray | ExtensionArray | pd.Categorical]
14231423
if PD_LTE_23:
1424-
valresult_type = np_1darray[Any]
1424+
valresult_type = np_1darray
14251425
else:
14261426
valresult_type = StringArray
14271427
check(
14281428
assert_type(
14291429
pd.Series(list("aabc")).values,
1430-
np_1darray[Any] | ExtensionArray | pd.Categorical,
1430+
np_1darray | ExtensionArray | pd.Categorical,
14311431
),
14321432
valresult_type,
14331433
str,
14341434
)
14351435
check(
14361436
assert_type(
14371437
pd.Series(list("aabc")).astype("category").values,
1438-
np_1darray[Any] | ExtensionArray | pd.Categorical,
1438+
np_1darray | ExtensionArray | pd.Categorical,
14391439
),
14401440
pd.Categorical,
14411441
str,
14421442
)
14431443
check(
14441444
assert_type(
14451445
pd.Series(pd.date_range("20130101", periods=3, tz="US/Eastern")).values,
1446-
np_1darray[Any] | ExtensionArray | pd.Categorical,
1446+
np_1darray | ExtensionArray | pd.Categorical,
14471447
),
14481448
np_1darray,
14491449
np.datetime64,

tests/test_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ def test_types_value_counts() -> None:
10881088
def test_types_unique() -> None:
10891089
# This is really more for of a Series test
10901090
df = pd.DataFrame(data={"col1": [1, 2], "col2": [1, 4]})
1091-
check(assert_type(df["col1"].unique(), np_1darray[Any]), np_1darray[Any])
1091+
check(assert_type(df["col1"].unique(), np_1darray), np_1darray)
10921092

10931093

10941094
def test_types_apply() -> None:

0 commit comments

Comments
 (0)