Skip to content

Commit 8bc0832

Browse files
authored
TYP: fix a few annotations in offsets.pyi (#46920)
* TYP: fix a few annotations in offsets.pyi * variation + calendar * None at the end
1 parent 0d24370 commit 8bc0832

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

pandas/_libs/tslibs/offsets.pyi

+38-16
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ from typing import (
99
Any,
1010
Collection,
1111
Literal,
12-
Tuple,
1312
TypeVar,
14-
Union,
1513
overload,
1614
)
1715

@@ -101,7 +99,7 @@ def _get_offset(name: str) -> BaseOffset: ...
10199

102100
class SingleConstructorOffset(BaseOffset):
103101
@classmethod
104-
def _from_name(cls, suffix=...): ...
102+
def _from_name(cls, suffix: None = ...): ...
105103
def __reduce__(self): ...
106104

107105
@overload
@@ -132,7 +130,7 @@ class RelativeDeltaOffset(BaseOffset):
132130
class BusinessMixin(SingleConstructorOffset):
133131
def __init__(
134132
self, n: int = ..., normalize: bool = ..., offset: timedelta = ...
135-
): ...
133+
) -> None: ...
136134

137135
class BusinessDay(BusinessMixin): ...
138136

@@ -144,14 +142,17 @@ class BusinessHour(BusinessMixin):
144142
start: str | Collection[str] = ...,
145143
end: str | Collection[str] = ...,
146144
offset: timedelta = ...,
147-
): ...
145+
) -> None: ...
148146

149-
class WeekOfMonthMixin(SingleConstructorOffset): ...
147+
class WeekOfMonthMixin(SingleConstructorOffset):
148+
def __init__(
149+
self, n: int = ..., normalize: bool = ..., weekday: int = ...
150+
) -> None: ...
150151

151152
class YearOffset(SingleConstructorOffset):
152153
def __init__(
153154
self, n: int = ..., normalize: bool = ..., month: int | None = ...
154-
): ...
155+
) -> None: ...
155156

156157
class BYearEnd(YearOffset): ...
157158
class BYearBegin(YearOffset): ...
@@ -186,7 +187,11 @@ class Week(SingleConstructorOffset):
186187
self, n: int = ..., normalize: bool = ..., weekday: int | None = ...
187188
) -> None: ...
188189

189-
class WeekOfMonth(WeekOfMonthMixin): ...
190+
class WeekOfMonth(WeekOfMonthMixin):
191+
def __init__(
192+
self, n: int = ..., normalize: bool = ..., week: int = ..., weekday: int = ...
193+
) -> None: ...
194+
190195
class LastWeekOfMonth(WeekOfMonthMixin): ...
191196

192197
class FY5253Mixin(SingleConstructorOffset):
@@ -196,41 +201,58 @@ class FY5253Mixin(SingleConstructorOffset):
196201
normalize: bool = ...,
197202
weekday: int = ...,
198203
startingMonth: int = ...,
199-
variation: str = ...,
204+
variation: Literal["nearest", "last"] = ...,
200205
) -> None: ...
201206

202207
class FY5253(FY5253Mixin): ...
203-
class FY5253Quarter(FY5253Mixin): ...
208+
209+
class FY5253Quarter(FY5253Mixin):
210+
def __init__(
211+
self,
212+
n: int = ...,
213+
normalize: bool = ...,
214+
weekday: int = ...,
215+
startingMonth: int = ...,
216+
qtr_with_extra_week: int = ...,
217+
variation: Literal["nearest", "last"] = ...,
218+
) -> None: ...
219+
204220
class Easter(SingleConstructorOffset): ...
205221

206222
class _CustomBusinessMonth(BusinessMixin):
207223
def __init__(
208224
self,
209225
n: int = ...,
210226
normalize: bool = ...,
227+
weekmask: str = ...,
228+
holidays: list | None = ...,
229+
calendar: np.busdaycalendar | None = ...,
211230
offset: timedelta = ...,
212-
holidays: None | list = ...,
213-
): ...
231+
) -> None: ...
214232

215233
class CustomBusinessDay(BusinessDay):
216234
def __init__(
217235
self,
218236
n: int = ...,
219237
normalize: bool = ...,
220-
offset: timedelta = ...,
221238
weekmask: str = ...,
222-
): ...
239+
holidays: list | None = ...,
240+
calendar: np.busdaycalendar | None = ...,
241+
offset: timedelta = ...,
242+
) -> None: ...
223243

224244
class CustomBusinessHour(BusinessHour):
225245
def __init__(
226246
self,
227247
n: int = ...,
228248
normalize: bool = ...,
249+
weekmask: str = ...,
250+
holidays: list | None = ...,
251+
calendar: np.busdaycalendar | None = ...,
229252
start: str = ...,
230253
end: str = ...,
231254
offset: timedelta = ...,
232-
holidays: None | list = ...,
233-
): ...
255+
) -> None: ...
234256

235257
class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
236258
class CustomBusinessMonthBegin(_CustomBusinessMonth): ...

pandas/_libs/tslibs/offsets.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3291,7 +3291,7 @@ cdef class CustomBusinessDay(BusinessDay):
32913291
holidays : list
32923292
List/array of dates to exclude from the set of valid business days,
32933293
passed to ``numpy.busdaycalendar``.
3294-
calendar : pd.HolidayCalendar or np.busdaycalendar
3294+
calendar : np.busdaycalendar
32953295
offset : timedelta, default timedelta(0)
32963296
"""
32973297

@@ -3417,7 +3417,7 @@ cdef class _CustomBusinessMonth(BusinessMixin):
34173417
holidays : list
34183418
List/array of dates to exclude from the set of valid business days,
34193419
passed to ``numpy.busdaycalendar``.
3420-
calendar : pd.HolidayCalendar or np.busdaycalendar
3420+
calendar : np.busdaycalendar
34213421
Calendar to integrate.
34223422
offset : timedelta, default timedelta(0)
34233423
Time offset to apply.

0 commit comments

Comments
 (0)