Skip to content

TYP: fix a few annotations in offsets.pyi #46920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 37 additions & 15 deletions pandas/_libs/tslibs/offsets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ from typing import (
Any,
Collection,
Literal,
Tuple,
TypeVar,
Union,
overload,
)

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

class SingleConstructorOffset(BaseOffset):
@classmethod
def _from_name(cls, suffix=...): ...
def _from_name(cls, suffix: None = ...): ...
def __reduce__(self): ...

@overload
Expand Down Expand Up @@ -132,7 +130,7 @@ class RelativeDeltaOffset(BaseOffset):
class BusinessMixin(SingleConstructorOffset):
def __init__(
self, n: int = ..., normalize: bool = ..., offset: timedelta = ...
): ...
) -> None: ...

class BusinessDay(BusinessMixin): ...

Expand All @@ -144,14 +142,17 @@ class BusinessHour(BusinessMixin):
start: str | Collection[str] = ...,
end: str | Collection[str] = ...,
offset: timedelta = ...,
): ...
) -> None: ...

class WeekOfMonthMixin(SingleConstructorOffset): ...
class WeekOfMonthMixin(SingleConstructorOffset):
def __init__(
self, n: int = ..., normalize: bool = ..., weekday: int = ...
) -> None: ...

class YearOffset(SingleConstructorOffset):
def __init__(
self, n: int = ..., normalize: bool = ..., month: int | None = ...
): ...
) -> None: ...

class BYearEnd(YearOffset): ...
class BYearBegin(YearOffset): ...
Expand Down Expand Up @@ -186,7 +187,11 @@ class Week(SingleConstructorOffset):
self, n: int = ..., normalize: bool = ..., weekday: int | None = ...
) -> None: ...

class WeekOfMonth(WeekOfMonthMixin): ...
class WeekOfMonth(WeekOfMonthMixin):
def __init__(
self, n: int = ..., normalize: bool = ..., week: int = ..., weekday: int = ...
) -> None: ...

class LastWeekOfMonth(WeekOfMonthMixin): ...

class FY5253Mixin(SingleConstructorOffset):
Expand All @@ -200,37 +205,54 @@ class FY5253Mixin(SingleConstructorOffset):
) -> None: ...

class FY5253(FY5253Mixin): ...
class FY5253Quarter(FY5253Mixin): ...

class FY5253Quarter(FY5253Mixin):
def __init__(
self,
n: int = ...,
normalize: bool = ...,
weekday: int = ...,
startingMonth: int = ...,
qtr_with_extra_week: int = ...,
variation: str = ...,
) -> None: ...

class Easter(SingleConstructorOffset): ...

class _CustomBusinessMonth(BusinessMixin):
def __init__(
self,
n: int = ...,
normalize: bool = ...,
offset: timedelta = ...,
weekmask: str = ...,
holidays: None | list = ...,
): ...
calendar: np.busdaycalendar = ...,
offset: timedelta = ...,
) -> None: ...

class CustomBusinessDay(BusinessDay):
def __init__(
self,
n: int = ...,
normalize: bool = ...,
offset: timedelta = ...,
weekmask: str = ...,
): ...
holidays: None | list = ...,
calendar: np.busdaycalendar = ...,
offset: timedelta = ...,
) -> None: ...

class CustomBusinessHour(BusinessHour):
def __init__(
self,
n: int = ...,
normalize: bool = ...,
weekmask: str = ...,
holidays: None | list = ...,
calendar: np.busdaycalendar = ...,
start: str = ...,
end: str = ...,
offset: timedelta = ...,
holidays: None | list = ...,
): ...
) -> None: ...

class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
class CustomBusinessMonthBegin(_CustomBusinessMonth): ...
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3291,7 +3291,7 @@ cdef class CustomBusinessDay(BusinessDay):
holidays : list
List/array of dates to exclude from the set of valid business days,
passed to ``numpy.busdaycalendar``.
calendar : pd.HolidayCalendar or np.busdaycalendar
calendar : np.busdaycalendar
offset : timedelta, default timedelta(0)
"""

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