Skip to content

Commit 68f4d5f

Browse files
authored
gh-520: Removed unnecassary types from S1 (#522)
* Modified S1 * Removed two datetime.* * req. changes * typo changes * removed datetime.* and modified the test likewise * Reverting changes made in last commit
1 parent 62e794a commit 68f4d5f

File tree

7 files changed

+29
-36
lines changed

7 files changed

+29
-36
lines changed

pandas-stubs/_libs/interval.pyi

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ from pandas import (
1313
Timedelta,
1414
Timestamp,
1515
)
16+
from pandas.core.series import (
17+
TimedeltaSeries,
18+
TimestampSeries,
19+
)
1620

1721
from pandas._typing import (
1822
IntervalClosedType,
@@ -170,23 +174,25 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
170174
@overload
171175
def __gt__(
172176
self,
173-
other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta],
177+
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
174178
) -> Series[bool]: ...
175179
@overload
176180
def __lt__(self, other: Interval[_OrderableT]) -> bool: ...
177181
@overload
178182
def __lt__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ...
179183
@overload
180184
def __lt__(
181-
self, other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta]
185+
self,
186+
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
182187
) -> Series[bool]: ...
183188
@overload
184189
def __ge__(self, other: Interval[_OrderableT]) -> bool: ...
185190
@overload
186191
def __ge__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ...
187192
@overload
188193
def __ge__(
189-
self, other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta]
194+
self,
195+
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
190196
) -> Series[bool]: ...
191197
@overload
192198
def __le__(self, other: Interval[_OrderableT]) -> bool: ...

pandas-stubs/_libs/tslibs/period.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,41 +101,41 @@ class Period(PeriodMixin):
101101
@overload
102102
def __eq__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
103103
@overload
104-
def __eq__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ... # type: ignore[misc]
104+
def __eq__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
105105
@overload
106106
def __eq__(self, other: object) -> Literal[False]: ...
107107
@overload
108108
def __ge__(self, other: Period) -> bool: ...
109109
@overload
110110
def __ge__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
111111
@overload
112-
def __ge__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
112+
def __ge__(self, other: PeriodSeries) -> Series[bool]: ...
113113
@overload
114114
def __gt__(self, other: Period) -> bool: ...
115115
@overload
116116
def __gt__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
117117
@overload
118-
def __gt__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
118+
def __gt__(self, other: PeriodSeries) -> Series[bool]: ...
119119
@overload
120120
def __le__(self, other: Period) -> bool: ...
121121
@overload
122122
def __le__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
123123
@overload
124-
def __le__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
124+
def __le__(self, other: PeriodSeries) -> Series[bool]: ...
125125
@overload
126126
def __lt__(self, other: Period) -> bool: ...
127127
@overload
128128
def __lt__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
129129
@overload
130-
def __lt__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
130+
def __lt__(self, other: PeriodSeries) -> Series[bool]: ...
131131
# ignore[misc] here because we know all other comparisons
132132
# are False, so we use Literal[False]
133133
@overload
134134
def __ne__(self, other: Period) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
135135
@overload
136136
def __ne__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
137137
@overload
138-
def __ne__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ... # type: ignore[misc]
138+
def __ne__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
139139
@overload
140140
def __ne__(self, other: object) -> Literal[True]: ...
141141
# Ignored due to indecipherable error from mypy:

pandas-stubs/_libs/tslibs/timedeltas.pyi

+6-11
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,11 @@ class Timedelta(timedelta):
169169
def __add__(self, other: pd.TimedeltaIndex) -> pd.TimedeltaIndex: ...
170170
@overload
171171
def __add__(
172-
self, other: TimedeltaSeries | Series[pd.Timedelta]
172+
self,
173+
other: TimedeltaSeries,
173174
) -> TimedeltaSeries: ...
174175
@overload
175-
def __add__(
176-
self, other: Series[Timestamp] | TimestampSeries
177-
) -> TimestampSeries: ...
176+
def __add__(self, other: TimestampSeries) -> TimestampSeries: ...
178177
@overload
179178
def __radd__(self, other: np.datetime64) -> Timestamp: ...
180179
@overload
@@ -277,9 +276,7 @@ class Timedelta(timedelta):
277276
@overload
278277
def __floordiv__(self, other: Series[float]) -> TimedeltaSeries: ...
279278
@overload
280-
def __floordiv__(
281-
self, other: Series[Timedelta] | TimedeltaSeries
282-
) -> Series[int]: ...
279+
def __floordiv__(self, other: TimedeltaSeries) -> Series[int]: ...
283280
@overload
284281
def __floordiv__(self, other: NaTType | None) -> float: ...
285282
@overload
@@ -300,9 +297,7 @@ class Timedelta(timedelta):
300297
self, other: npt.NDArray[np.integer] | npt.NDArray[np.floating]
301298
) -> npt.NDArray[np.timedelta64]: ...
302299
@overload
303-
def __truediv__(
304-
self, other: Series[Timedelta] | TimedeltaSeries
305-
) -> Series[float]: ...
300+
def __truediv__(self, other: TimedeltaSeries) -> Series[float]: ...
306301
@overload
307302
def __truediv__(self, other: Series[int]) -> TimedeltaSeries: ...
308303
@overload
@@ -347,7 +342,7 @@ class Timedelta(timedelta):
347342
) -> npt.NDArray[np.timedelta64]: ...
348343
@overload
349344
def __mod__(
350-
self, other: Series[int] | Series[float] | Series[Timedelta] | TimedeltaSeries
345+
self, other: Series[int] | Series[float] | TimedeltaSeries
351346
) -> TimedeltaSeries: ...
352347
def __divmod__(self, other: timedelta) -> tuple[int, Timedelta]: ...
353348
# Mypy complains Forward operator "<inequality op>" is not callable, so ignore misc

pandas-stubs/_libs/tslibs/timestamps.pyi

+7-9
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,25 @@ class Timestamp(datetime):
159159
@overload
160160
def __le__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
161161
@overload
162-
def __le__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
162+
def __le__(self, other: TimestampSeries) -> Series[bool]: ...
163163
@overload # type: ignore[override]
164164
def __lt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
165165
@overload
166166
def __lt__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
167167
@overload
168-
def __lt__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
168+
def __lt__(self, other: TimestampSeries) -> Series[bool]: ...
169169
@overload # type: ignore[override]
170170
def __ge__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
171171
@overload
172172
def __ge__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
173173
@overload
174-
def __ge__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
174+
def __ge__(self, other: TimestampSeries) -> Series[bool]: ...
175175
@overload # type: ignore[override]
176176
def __gt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
177177
@overload
178178
def __gt__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
179179
@overload
180-
def __gt__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
180+
def __gt__(self, other: TimestampSeries) -> Series[bool]: ...
181181
# error: Signature of "__add__" incompatible with supertype "date"/"datetime"
182182
@overload # type: ignore[override]
183183
def __add__(
@@ -188,9 +188,7 @@ class Timestamp(datetime):
188188
self: _DatetimeT, other: timedelta | np.timedelta64 | Tick
189189
) -> _DatetimeT: ...
190190
@overload
191-
def __add__(
192-
self, other: TimedeltaSeries | Series[Timedelta]
193-
) -> TimestampSeries: ...
191+
def __add__(self, other: TimedeltaSeries) -> TimestampSeries: ...
194192
@overload
195193
def __add__(self, other: TimedeltaIndex) -> DatetimeIndex: ...
196194
@overload
@@ -219,15 +217,15 @@ class Timestamp(datetime):
219217
@overload
220218
def __eq__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
221219
@overload
222-
def __eq__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ... # type: ignore[misc]
220+
def __eq__(self, other: TimestampSeries | Series[np.datetime64]) -> Series[bool]: ... # type: ignore[misc]
223221
@overload
224222
def __eq__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
225223
@overload
226224
def __eq__(self, other: object) -> Literal[False]: ...
227225
@overload
228226
def __ne__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
229227
@overload
230-
def __ne__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ... # type: ignore[misc]
228+
def __ne__(self, other: TimestampSeries | Series[np.datetime64]) -> Series[bool]: ... # type: ignore[misc]
231229
@overload
232230
def __ne__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
233231
@overload

pandas-stubs/_typing.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ S1 = TypeVar(
197197
str,
198198
bytes,
199199
datetime.date,
200-
datetime.datetime,
201200
datetime.time,
202-
datetime.timedelta,
203201
bool,
204202
int,
205203
float,

pandas-stubs/core/indexes/interval.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ _EdgesFloat: TypeAlias = Union[
5656
_EdgesTimestamp: TypeAlias = Union[
5757
Sequence[DatetimeLike],
5858
npt.NDArray[np.datetime64],
59-
pd.Series[pd.Timestamp],
6059
TimestampSeries,
6160
pd.DatetimeIndex,
6261
]
6362
_EdgesTimedelta: TypeAlias = Union[
6463
Sequence[pd.Timedelta],
6564
npt.NDArray[np.timedelta64],
66-
pd.Series[pd.Timedelta],
6765
TimedeltaSeries,
6866
pd.TimedeltaIndex,
6967
]

tests/test_scalars.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1256,9 +1256,7 @@ def test_timestamp_cmp() -> None:
12561256
c_dt_datetime = dt.datetime(year=2000, month=1, day=1)
12571257
c_datetimeindex = pd.DatetimeIndex(["2000-1-1"])
12581258
c_np_ndarray_dt64 = np_dt64_arr
1259-
# Typing provided since there is no way to get a Series[Timestamp],
1260-
# which is a different type from a TimestampSeries
1261-
c_series_dt64: pd.Series[pd.Timestamp] = pd.Series(
1259+
c_series_dt64: pd.Series[np.datetime64] = pd.Series(
12621260
[1, 2, 3], dtype="datetime64[ns]"
12631261
)
12641262
c_series_timestamp = pd.Series(pd.DatetimeIndex(["2000-1-1"]))

0 commit comments

Comments
 (0)