Skip to content

Commit a1f6056

Browse files
authored
TYP: annotate tseries.holiday (#35913)
1 parent e3bcf8d commit a1f6056

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

pandas/tseries/holiday.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pandas.tseries.offsets import Day, Easter
1313

1414

15-
def next_monday(dt):
15+
def next_monday(dt: datetime) -> datetime:
1616
"""
1717
If holiday falls on Saturday, use following Monday instead;
1818
if holiday falls on Sunday, use Monday instead
@@ -24,7 +24,7 @@ def next_monday(dt):
2424
return dt
2525

2626

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

4141

42-
def previous_friday(dt):
42+
def previous_friday(dt: datetime) -> datetime:
4343
"""
4444
If holiday falls on Saturday or Sunday, use previous Friday instead.
4545
"""
@@ -50,7 +50,7 @@ def previous_friday(dt):
5050
return dt
5151

5252

53-
def sunday_to_monday(dt):
53+
def sunday_to_monday(dt: datetime) -> datetime:
5454
"""
5555
If holiday falls on Sunday, use day thereafter (Monday) instead.
5656
"""
@@ -59,7 +59,7 @@ def sunday_to_monday(dt):
5959
return dt
6060

6161

62-
def weekend_to_monday(dt):
62+
def weekend_to_monday(dt: datetime) -> datetime:
6363
"""
6464
If holiday falls on Sunday or Saturday,
6565
use day thereafter (Monday) instead.
@@ -72,7 +72,7 @@ def weekend_to_monday(dt):
7272
return dt
7373

7474

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

8686

87-
def next_workday(dt):
87+
def next_workday(dt: datetime) -> datetime:
8888
"""
8989
returns next weekday used for observances
9090
"""
@@ -95,7 +95,7 @@ def next_workday(dt):
9595
return dt
9696

9797

98-
def previous_workday(dt):
98+
def previous_workday(dt: datetime) -> datetime:
9999
"""
100100
returns previous weekday used for observances
101101
"""
@@ -106,14 +106,14 @@ def previous_workday(dt):
106106
return dt
107107

108108

109-
def before_nearest_workday(dt):
109+
def before_nearest_workday(dt: datetime) -> datetime:
110110
"""
111111
returns previous workday after nearest workday
112112
"""
113113
return previous_workday(nearest_workday(dt))
114114

115115

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

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,3 @@ check_untyped_defs=False
276276

277277
[mypy-pandas.plotting._matplotlib.misc]
278278
check_untyped_defs=False
279-
280-
[mypy-pandas.tseries.holiday]
281-
check_untyped_defs=False

0 commit comments

Comments
 (0)