Skip to content

Commit 84eb759

Browse files
msfterictrauttwoertwein
authored andcommitted
Fixed formatting issues
1 parent b9cb593 commit 84eb759

29 files changed

+315
-144
lines changed

pandas/_libs/interval.pyi

-47
This file was deleted.

pandas/_libs/tslibs/nattype.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ iNaT: int
1414
nat_strings: set[str]
1515

1616
def is_null_datetimelike(val: object, inat_is_null: bool = ...) -> bool: ...
17-
def checknull_with_nat(val: object) -> bool: ...
1817

1918
class NaTType(datetime):
2019
value: np.int64

pandas/_libs/tslibs/offsets.pyi

+177-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
from __future__ import annotations
2-
from datetime import datetime
3-
from typing import Any, Tuple, Union
4-
from datetime import timedelta
2+
3+
from datetime import (
4+
datetime,
5+
timedelta,
6+
)
7+
from typing import (
8+
TYPE_CHECKING,
9+
Any,
10+
Collection,
11+
Literal,
12+
Tuple,
13+
TypeVar,
14+
Union,
15+
overload,
16+
)
17+
18+
import numpy as np
19+
20+
from pandas._typing import npt
21+
22+
from .timedeltas import Timedelta
23+
24+
if TYPE_CHECKING:
25+
from pandas.core.indexes.datetimes import DatetimeIndex
26+
_BaseOffsetT = TypeVar("_BaseOffsetT", bound="BaseOffset")
27+
_DatetimeT = TypeVar("_DatetimeT", bound=datetime)
28+
_TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta)
29+
30+
_relativedelta_kwds: set[str]
31+
prefix_mapping: dict[str, type]
32+
33+
class ApplyTypeError(TypeError): ...
534

635
class BaseOffset:
36+
n: int
737
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
838
def __eq__(self, other) -> bool: ...
939
def __ne__(self, other) -> bool: ...
@@ -12,21 +42,49 @@ class BaseOffset:
1242
def kwds(self) -> dict: ...
1343
@property
1444
def base(self) -> BaseOffset: ...
15-
def __add__(self, other) -> BaseOffset: ...
16-
def __sub__(self, other) -> BaseOffset: ...
45+
@overload
46+
def __add__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
47+
@overload
48+
def __add__(self: _BaseOffsetT, other: BaseOffset) -> _BaseOffsetT: ...
49+
@overload
50+
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
51+
@overload
52+
def __add__(self, other: _TimedeltaT) -> _TimedeltaT: ...
53+
@overload
54+
def __radd__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
55+
@overload
56+
def __radd__(self: _BaseOffsetT, other: BaseOffset) -> _BaseOffsetT: ...
57+
@overload
58+
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
59+
@overload
60+
def __radd__(self, other: _TimedeltaT) -> _TimedeltaT: ...
61+
def __sub__(self: _BaseOffsetT, other: BaseOffset) -> _BaseOffsetT: ...
62+
@overload
63+
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
64+
@overload
65+
def __rsub__(self: _BaseOffsetT, other: BaseOffset) -> _BaseOffsetT: ...
66+
@overload
67+
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...
68+
@overload
69+
def __rsub__(self, other: _TimedeltaT) -> _TimedeltaT: ...
1770
def __call__(self, other): ...
18-
def __mul__(self, other): ...
19-
def __neg__(self) -> BaseOffset: ...
20-
def copy(self) -> BaseOffset: ...
71+
@overload
72+
def __mul__(self, other: np.ndarray) -> np.ndarray: ...
73+
@overload
74+
def __mul__(self: _BaseOffsetT, other: int) -> _BaseOffsetT: ...
75+
@overload
76+
def __rmul__(self, other: np.ndarray) -> np.ndarray: ...
77+
@overload
78+
def __rmul__(self: _BaseOffsetT, other: int) -> _BaseOffsetT: ...
79+
def __neg__(self: _BaseOffsetT) -> _BaseOffsetT: ...
80+
def copy(self: _BaseOffsetT) -> _BaseOffsetT: ...
2181
def __repr__(self) -> str: ...
2282
@property
2383
def name(self) -> str: ...
2484
@property
2585
def rule_code(self) -> str: ...
2686
def freqstr(self) -> str: ...
27-
# Next one is problematic due to circular imports
28-
#def apply_index(self, dtindex: DatetimeIndex) -> DatetimeIndex: ...
29-
def apply_index(self, dtindex): ...
87+
def apply_index(self, dtindex: "DatetimeIndex") -> "DatetimeIndex": ...
3088
def _apply_array(self, dtarr) -> None: ...
3189
def rollback(self, dt: datetime) -> datetime: ...
3290
def rollforward(self, dt: datetime) -> datetime: ...
@@ -39,15 +97,26 @@ class BaseOffset:
3997
def isAnchored(self) -> bool: ...
4098
def is_anchored(self) -> bool: ...
4199

100+
def _get_offset(name: str) -> BaseOffset: ...
101+
42102
class SingleConstructorOffset(BaseOffset):
43103
@classmethod
44-
def _from_name(cls, suffix=None): ...
104+
def _from_name(cls, suffix=...): ...
45105
def __reduce__(self): ...
46106

47-
def to_offset(freq: Union[str, Tuple, timedelta, BaseOffset, None]) -> Union[BaseOffset, None]: ...
107+
@overload
108+
def to_offset(freq: None) -> None: ...
109+
@overload
110+
def to_offset(freq: timedelta | BaseOffset | str) -> BaseOffset: ...
48111

49112
class Tick(SingleConstructorOffset):
50113
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ...
114+
@property
115+
def delta(self) -> Timedelta: ...
116+
@property
117+
def nanos(self) -> int: ...
118+
119+
def delta_to_tick(delta: timedelta) -> Tick: ...
51120

52121
class Day(Tick): ...
53122
class Hour(Tick): ...
@@ -56,18 +125,44 @@ class Second(Tick): ...
56125
class Milli(Tick): ...
57126
class Micro(Tick): ...
58127
class Nano(Tick): ...
128+
59129
class RelativeDeltaOffset(BaseOffset):
60130
def __init__(self, n: int = ..., normalize: bool = ..., **kwds: Any) -> None: ...
61-
class BusinessMixin(SingleConstructorOffset): ...
131+
132+
class BusinessMixin(SingleConstructorOffset):
133+
def __init__(
134+
self, n: int = ..., normalize: bool = ..., offset: timedelta = ...
135+
): ...
136+
62137
class BusinessDay(BusinessMixin): ...
63-
class BusinessHour(BusinessMixin): ...
138+
139+
class BusinessHour(BusinessMixin):
140+
def __init__(
141+
self,
142+
n: int = ...,
143+
normalize: bool = ...,
144+
start: str | Collection[str] = ...,
145+
end: str | Collection[str] = ...,
146+
offset: timedelta = ...,
147+
): ...
148+
64149
class WeekOfMonthMixin(SingleConstructorOffset): ...
65-
class YearOffset(SingleConstructorOffset): ...
150+
151+
class YearOffset(SingleConstructorOffset):
152+
def __init__(
153+
self, n: int = ..., normalize: bool = ..., month: int | None = ...
154+
): ...
155+
66156
class BYearEnd(YearOffset): ...
67157
class BYearBegin(YearOffset): ...
68158
class YearEnd(YearOffset): ...
69159
class YearBegin(YearOffset): ...
70-
class QuarterOffset(SingleConstructorOffset): ...
160+
161+
class QuarterOffset(SingleConstructorOffset):
162+
def __init__(
163+
self, n: int = ..., normalize: bool = ..., startingMonth: int | None = ...
164+
) -> None: ...
165+
71166
class BQuarterEnd(QuarterOffset): ...
72167
class BQuarterBegin(QuarterOffset): ...
73168
class QuarterEnd(QuarterOffset): ...
@@ -77,19 +172,66 @@ class MonthEnd(MonthOffset): ...
77172
class MonthBegin(MonthOffset): ...
78173
class BusinessMonthEnd(MonthOffset): ...
79174
class BusinessMonthBegin(MonthOffset): ...
80-
class SemiMonthOffset(SingleConstructorOffset): ...
175+
176+
class SemiMonthOffset(SingleConstructorOffset):
177+
def __init__(
178+
self, n: int = ..., normalize: bool = ..., day_of_month: int | None = ...
179+
) -> None: ...
180+
81181
class SemiMonthEnd(SemiMonthOffset): ...
82182
class SemiMonthBegin(SemiMonthOffset): ...
83-
class Week(SingleConstructorOffset): ...
183+
184+
class Week(SingleConstructorOffset):
185+
def __init__(
186+
self, n: int = ..., normalize: bool = ..., weekday: int | None = ...
187+
) -> None: ...
188+
84189
class WeekOfMonth(WeekOfMonthMixin): ...
85190
class LastWeekOfMonth(WeekOfMonthMixin): ...
86-
class FY5253Mixin(SingleConstructorOffset): ...
191+
192+
class FY5253Mixin(SingleConstructorOffset):
193+
def __init__(
194+
self,
195+
n: int = ...,
196+
normalize: bool = ...,
197+
weekday: int = ...,
198+
startingMonth: int = ...,
199+
variation: str = ...,
200+
) -> None: ...
201+
87202
class FY5253(FY5253Mixin): ...
88203
class FY5253Quarter(FY5253Mixin): ...
89204
class Easter(SingleConstructorOffset): ...
90-
class _CustomBusinessMonth(BusinessMixin): ...
91-
class CustomBusinessDay(BusinessDay): ...
92-
class CustomBusinessHour(BusinessHour): ...
205+
206+
class _CustomBusinessMonth(BusinessMixin):
207+
def __init__(
208+
self,
209+
n: int = ...,
210+
normalize: bool = ...,
211+
offset: timedelta = ...,
212+
holidays: None | list = ...,
213+
): ...
214+
215+
class CustomBusinessDay(BusinessDay):
216+
def __init__(
217+
self,
218+
n: int = ...,
219+
normalize: bool = ...,
220+
offset: timedelta = ...,
221+
weekmask: str = ...,
222+
): ...
223+
224+
class CustomBusinessHour(BusinessHour):
225+
def __init__(
226+
self,
227+
n: int = ...,
228+
normalize: bool = ...,
229+
start: str = ...,
230+
end: str = ...,
231+
offset: timedelta = ...,
232+
holidays: None | list = ...,
233+
): ...
234+
93235
class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
94236
class CustomBusinessMonthBegin(_CustomBusinessMonth): ...
95237
class DateOffset(RelativeDeltaOffset): ...
@@ -100,3 +242,15 @@ BMonthBegin = BusinessMonthBegin
100242
CBMonthEnd = CustomBusinessMonthEnd
101243
CBMonthBegin = CustomBusinessMonthBegin
102244
CDay = CustomBusinessDay
245+
246+
def roll_qtrday(
247+
other: datetime, n: int, month: int, day_opt: str, modby: int
248+
) -> int: ...
249+
250+
INVALID_FREQ_ERR_MSG: Literal["Invalid frequency: {0}"]
251+
252+
def shift_months(
253+
dtindex: npt.NDArray[np.int64], months: int, day_opt: str | None = ...
254+
) -> npt.NDArray[np.int64]: ...
255+
256+
_offset_map: dict[str, BaseOffset]

pandas/_libs/tslibs/period.pyi

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import timedelta
22
from typing import Literal
33

44
import numpy as np
@@ -15,9 +15,6 @@ from pandas._typing import (
1515
INVALID_FREQ_ERR_MSG: str
1616
DIFFERENT_FREQ: str
1717

18-
def is_period_object(obj: object) -> bool: ...
19-
def get_period_ordinal(dts: datetime, freq: int) -> int: ...
20-
2118
class IncompatibleFrequency(ValueError): ...
2219

2320
def periodarr_to_dt64arr(
@@ -37,7 +34,7 @@ def get_period_field_arr(
3734
) -> npt.NDArray[np.int64]: ...
3835
def from_ordinals(
3936
values: npt.NDArray[np.int64], # const int64_t[:]
40-
freq: Frequency,
37+
freq: timedelta | BaseOffset | str | None,
4138
) -> npt.NDArray[np.int64]: ...
4239
def extract_ordinals(
4340
values: npt.NDArray[np.object_],
@@ -63,7 +60,7 @@ class Period:
6360
def __new__( # type: ignore[misc]
6461
cls,
6562
value=...,
66-
freq: int | str | None = ...,
63+
freq: int | str | BaseOffset | None = ...,
6764
ordinal: int | None = ...,
6865
year: int | None = ...,
6966
month: int | None = ...,
@@ -86,7 +83,7 @@ class Period:
8683
how: str = ...,
8784
tz: Timezone | None = ...,
8885
) -> Timestamp: ...
89-
def asfreq(self, freq: str, how: str = ...) -> Period: ...
86+
def asfreq(self, freq: str | BaseOffset, how: str = ...) -> Period: ...
9087
@property
9188
def freqstr(self) -> str: ...
9289
@property

pandas/_libs/tslibs/period.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ cdef class _Period(PeriodMixin):
17951795

17961796
Parameters
17971797
----------
1798-
freq : str
1798+
freq : str, BaseOffset
17991799
The desired frequency.
18001800
how : {'E', 'S', 'end', 'start'}, default 'end'
18011801
Start or end of the timespan.

pandas/_libs/tslibs/timedeltas.pyi

+11-2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,19 @@ class Timedelta(timedelta):
6767
def __abs__(self) -> timedelta: ...
6868
def __mul__(self, other: float) -> timedelta: ...
6969
def __rmul__(self, other: float) -> timedelta: ...
70-
@overload
70+
# error: Signature of "__floordiv__" incompatible with supertype "timedelta"
71+
@overload # type: ignore[override]
7172
def __floordiv__(self, other: timedelta) -> int: ...
7273
@overload
73-
def __floordiv__(self, other: int) -> timedelta: ...
74+
def __floordiv__(self, other: int | float) -> timedelta: ...
75+
@overload
76+
def __floordiv__(self, other: np.ndarray) -> npt.NDArray[np.timedelta64]: ...
77+
@overload
78+
def __rfloordiv__(self, other: timedelta) -> int: ...
79+
@overload
80+
def __rfloordiv__(self, other: int | float) -> timedelta: ...
81+
@overload
82+
def __rfloordiv__(self, other: np.ndarray) -> npt.NDArray[np.timedelta64]: ...
7483
@overload
7584
def __truediv__(self, other: timedelta) -> float: ...
7685
@overload

0 commit comments

Comments
 (0)