Skip to content

Commit e12b318

Browse files
authored
TYP/CLN: small cleanups from flake-pyi (#47850)
* TYP/CLN: small cleanups from flake-pyi * black * manual changes in py files * some more cases
1 parent 6b7578b commit e12b318

23 files changed

+52
-66
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ repos:
230230
language: python
231231
additional_dependencies:
232232
- flake8==4.0.1
233-
- flake8-pyi==22.5.1
233+
- flake8-pyi==22.7.0
234234
- id: future-annotations
235235
name: import annotations from __future__
236236
entry: 'from __future__ import annotations'

pandas/_libs/algos.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from typing import Any
42

53
import numpy as np

pandas/_libs/interval.pyi

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from typing import (
42
Any,
53
Generic,
@@ -84,7 +82,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
8482
self: Interval[_OrderableTimesT], key: _OrderableTimesT
8583
) -> bool: ...
8684
@overload
87-
def __contains__(self: Interval[_OrderableScalarT], key: int | float) -> bool: ...
85+
def __contains__(self: Interval[_OrderableScalarT], key: float) -> bool: ...
8886
@overload
8987
def __add__(
9088
self: Interval[_OrderableTimesT], y: Timedelta
@@ -94,7 +92,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
9492
self: Interval[int], y: _OrderableScalarT
9593
) -> Interval[_OrderableScalarT]: ...
9694
@overload
97-
def __add__(self: Interval[float], y: int | float) -> Interval[float]: ...
95+
def __add__(self: Interval[float], y: float) -> Interval[float]: ...
9896
@overload
9997
def __radd__(
10098
self: Interval[_OrderableTimesT], y: Timedelta
@@ -104,7 +102,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
104102
self: Interval[int], y: _OrderableScalarT
105103
) -> Interval[_OrderableScalarT]: ...
106104
@overload
107-
def __radd__(self: Interval[float], y: int | float) -> Interval[float]: ...
105+
def __radd__(self: Interval[float], y: float) -> Interval[float]: ...
108106
@overload
109107
def __sub__(
110108
self: Interval[_OrderableTimesT], y: Timedelta
@@ -114,7 +112,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
114112
self: Interval[int], y: _OrderableScalarT
115113
) -> Interval[_OrderableScalarT]: ...
116114
@overload
117-
def __sub__(self: Interval[float], y: int | float) -> Interval[float]: ...
115+
def __sub__(self: Interval[float], y: float) -> Interval[float]: ...
118116
@overload
119117
def __rsub__(
120118
self: Interval[_OrderableTimesT], y: Timedelta
@@ -124,31 +122,31 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
124122
self: Interval[int], y: _OrderableScalarT
125123
) -> Interval[_OrderableScalarT]: ...
126124
@overload
127-
def __rsub__(self: Interval[float], y: int | float) -> Interval[float]: ...
125+
def __rsub__(self: Interval[float], y: float) -> Interval[float]: ...
128126
@overload
129127
def __mul__(
130128
self: Interval[int], y: _OrderableScalarT
131129
) -> Interval[_OrderableScalarT]: ...
132130
@overload
133-
def __mul__(self: Interval[float], y: int | float) -> Interval[float]: ...
131+
def __mul__(self: Interval[float], y: float) -> Interval[float]: ...
134132
@overload
135133
def __rmul__(
136134
self: Interval[int], y: _OrderableScalarT
137135
) -> Interval[_OrderableScalarT]: ...
138136
@overload
139-
def __rmul__(self: Interval[float], y: int | float) -> Interval[float]: ...
137+
def __rmul__(self: Interval[float], y: float) -> Interval[float]: ...
140138
@overload
141139
def __truediv__(
142140
self: Interval[int], y: _OrderableScalarT
143141
) -> Interval[_OrderableScalarT]: ...
144142
@overload
145-
def __truediv__(self: Interval[float], y: int | float) -> Interval[float]: ...
143+
def __truediv__(self: Interval[float], y: float) -> Interval[float]: ...
146144
@overload
147145
def __floordiv__(
148146
self: Interval[int], y: _OrderableScalarT
149147
) -> Interval[_OrderableScalarT]: ...
150148
@overload
151-
def __floordiv__(self: Interval[float], y: int | float) -> Interval[float]: ...
149+
def __floordiv__(self: Interval[float], y: float) -> Interval[float]: ...
152150
def overlaps(self: Interval[_OrderableT], other: Interval[_OrderableT]) -> bool: ...
153151

154152
def intervals_to_interval_bounds(

pandas/_libs/join.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def asof_join_backward_on_X_by_Y(
5555
left_by_values: np.ndarray, # by_t[:]
5656
right_by_values: np.ndarray, # by_t[:]
5757
allow_exact_matches: bool = ...,
58-
tolerance: np.number | int | float | None = ...,
58+
tolerance: np.number | float | None = ...,
5959
use_hashtable: bool = ...,
6060
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
6161
def asof_join_forward_on_X_by_Y(
@@ -64,7 +64,7 @@ def asof_join_forward_on_X_by_Y(
6464
left_by_values: np.ndarray, # by_t[:]
6565
right_by_values: np.ndarray, # by_t[:]
6666
allow_exact_matches: bool = ...,
67-
tolerance: np.number | int | float | None = ...,
67+
tolerance: np.number | float | None = ...,
6868
use_hashtable: bool = ...,
6969
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
7070
def asof_join_nearest_on_X_by_Y(
@@ -73,6 +73,6 @@ def asof_join_nearest_on_X_by_Y(
7373
left_by_values: np.ndarray, # by_t[:]
7474
right_by_values: np.ndarray, # by_t[:]
7575
allow_exact_matches: bool = ...,
76-
tolerance: np.number | int | float | None = ...,
76+
tolerance: np.number | float | None = ...,
7777
use_hashtable: bool = ...,
7878
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...

pandas/_libs/json.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def dumps(
1212
date_unit: str = ...,
1313
iso_dates: bool = ...,
1414
default_handler: None
15-
| Callable[[Any], str | int | float | bool | list | dict | None] = ...,
15+
| Callable[[Any], str | float | bool | list | dict | None] = ...,
1616
) -> str: ...
1717
def loads(
1818
s: str,

pandas/_libs/tslibs/offsets.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from datetime import (
42
datetime,
53
timedelta,

pandas/_libs/tslibs/timedeltas.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Timedelta(timedelta):
8686
cls: type[_S],
8787
value=...,
8888
unit: str = ...,
89-
**kwargs: int | float | np.integer | np.floating,
89+
**kwargs: float | np.integer | np.floating,
9090
) -> _S: ...
9191
# GH 46171
9292
# While Timedelta can return pd.NaT, having the constructor return
@@ -123,7 +123,7 @@ class Timedelta(timedelta):
123123
@overload # type: ignore[override]
124124
def __floordiv__(self, other: timedelta) -> int: ...
125125
@overload
126-
def __floordiv__(self, other: int | float) -> Timedelta: ...
126+
def __floordiv__(self, other: float) -> Timedelta: ...
127127
@overload
128128
def __floordiv__(
129129
self, other: npt.NDArray[np.timedelta64]

pandas/_libs/tslibs/timestamps.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ class Timestamp(datetime):
3333
value: int # np.int64
3434
def __new__(
3535
cls: type[_DatetimeT],
36-
ts_input: int
37-
| np.integer
38-
| float
39-
| str
40-
| _date
41-
| datetime
42-
| np.datetime64 = ...,
36+
ts_input: np.integer | float | str | _date | datetime | np.datetime64 = ...,
4337
freq: int | None | str | BaseOffset = ...,
4438
tz: str | _tzinfo | None | int = ...,
4539
unit: str | int | None = ...,

pandas/_libs/writers.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import numpy as np
42

53
from pandas._typing import ArrayLike

pandas/_typing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
# scalars
8484

85-
PythonScalar = Union[str, int, float, bool]
85+
PythonScalar = Union[str, float, bool]
8686
DatetimeLikeScalar = Union["Period", "Timestamp", "Timedelta"]
8787
PandasScalar = Union["Period", "Timestamp", "Timedelta", "Interval"]
8888
Scalar = Union[PythonScalar, PandasScalar, np.datetime64, np.timedelta64, datetime]
@@ -92,10 +92,10 @@
9292
# timestamp and timedelta convertible types
9393

9494
TimestampConvertibleTypes = Union[
95-
"Timestamp", datetime, np.datetime64, int, np.int64, float, str
95+
"Timestamp", datetime, np.datetime64, np.int64, float, str
9696
]
9797
TimedeltaConvertibleTypes = Union[
98-
"Timedelta", timedelta, np.timedelta64, int, np.int64, float, str
98+
"Timedelta", timedelta, np.timedelta64, np.int64, float, str
9999
]
100100
Timezone = Union[str, tzinfo]
101101

@@ -126,7 +126,7 @@
126126
]
127127

128128
# dtypes
129-
NpDtype = Union[str, np.dtype, type_t[Union[str, float, int, complex, bool, object]]]
129+
NpDtype = Union[str, np.dtype, type_t[Union[str, complex, bool, object]]]
130130
Dtype = Union["ExtensionDtype", NpDtype]
131131
AstypeArg = Union["ExtensionDtype", "npt.DTypeLike"]
132132
# DtypeArg specifies all allowable dtypes in a functions its dtype argument

0 commit comments

Comments
 (0)