Skip to content

TYP: annotate tseries.holiday #35913

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 17 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4c5eddd
REF: remove unnecesary try/except
jbrockmendel Aug 21, 2020
c632c9f
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
9e64be3
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
42649fb
TST: add test for agg on ordered categorical cols (#35630)
mathurk1 Aug 21, 2020
47121dd
TST: resample does not yield empty groups (#10603) (#35799)
tkmz-n Aug 21, 2020
1decb3e
revert accidental rebase
jbrockmendel Aug 22, 2020
57c5dd3
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 22, 2020
a358463
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
ffa7ad7
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
e5e98d4
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
408db5a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
d3493cf
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
75a805a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
9f61070
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
2d10f6e
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 26, 2020
3e20187
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 26, 2020
bb9e97e
TYP: annotate tseries.holiday
jbrockmendel Aug 27, 2020
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
28 changes: 15 additions & 13 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pandas.tseries.offsets import Day, Easter


def next_monday(dt):
def next_monday(dt: datetime) -> datetime:
"""
If holiday falls on Saturday, use following Monday instead;
if holiday falls on Sunday, use Monday instead
Expand All @@ -24,7 +24,7 @@ def next_monday(dt):
return dt


def next_monday_or_tuesday(dt):
def next_monday_or_tuesday(dt: datetime) -> datetime:
"""
For second holiday of two adjacent ones!
If holiday falls on Saturday, use following Monday instead;
Expand All @@ -39,7 +39,7 @@ def next_monday_or_tuesday(dt):
return dt


def previous_friday(dt):
def previous_friday(dt: datetime) -> datetime:
"""
If holiday falls on Saturday or Sunday, use previous Friday instead.
"""
Expand All @@ -50,7 +50,7 @@ def previous_friday(dt):
return dt


def sunday_to_monday(dt):
def sunday_to_monday(dt: datetime) -> datetime:
"""
If holiday falls on Sunday, use day thereafter (Monday) instead.
"""
Expand All @@ -59,7 +59,7 @@ def sunday_to_monday(dt):
return dt


def weekend_to_monday(dt):
def weekend_to_monday(dt: datetime) -> datetime:
"""
If holiday falls on Sunday or Saturday,
use day thereafter (Monday) instead.
Expand All @@ -72,7 +72,7 @@ def weekend_to_monday(dt):
return dt


def nearest_workday(dt):
def nearest_workday(dt: datetime) -> datetime:
"""
If holiday falls on Saturday, use day before (Friday) instead;
if holiday falls on Sunday, use day thereafter (Monday) instead.
Expand All @@ -84,7 +84,7 @@ def nearest_workday(dt):
return dt


def next_workday(dt):
def next_workday(dt: datetime) -> datetime:
"""
returns next weekday used for observances
"""
Expand All @@ -95,7 +95,7 @@ def next_workday(dt):
return dt


def previous_workday(dt):
def previous_workday(dt: datetime) -> datetime:
"""
returns previous weekday used for observances
"""
Expand All @@ -106,14 +106,14 @@ def previous_workday(dt):
return dt


def before_nearest_workday(dt):
def before_nearest_workday(dt: datetime) -> datetime:
"""
returns previous workday after nearest workday
"""
return previous_workday(nearest_workday(dt))


def after_nearest_workday(dt):
def after_nearest_workday(dt: datetime) -> datetime:
"""
returns next workday after nearest workday
needed for Boxing day or multiple holidays in a series
Expand Down Expand Up @@ -428,9 +428,11 @@ def holidays(self, start=None, end=None, return_name=False):
# If we don't have a cache or the dates are outside the prior cache, we
# get them again
if self._cache is None or start < self._cache[0] or end > self._cache[1]:
holidays = [rule.dates(start, end, return_name=True) for rule in self.rules]
if holidays:
holidays = concat(holidays)
pre_holidays = [
rule.dates(start, end, return_name=True) for rule in self.rules
]
if pre_holidays:
holidays = concat(pre_holidays)
else:
holidays = Series(index=DatetimeIndex([]), dtype=object)

Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,3 @@ check_untyped_defs=False

[mypy-pandas.plotting._matplotlib.misc]
check_untyped_defs=False

[mypy-pandas.tseries.holiday]
check_untyped_defs=False