12
12
from pandas .tseries .offsets import Day , Easter
13
13
14
14
15
- def next_monday (dt ) :
15
+ def next_monday (dt : datetime ) -> datetime :
16
16
"""
17
17
If holiday falls on Saturday, use following Monday instead;
18
18
if holiday falls on Sunday, use Monday instead
@@ -24,7 +24,7 @@ def next_monday(dt):
24
24
return dt
25
25
26
26
27
- def next_monday_or_tuesday (dt ) :
27
+ def next_monday_or_tuesday (dt : datetime ) -> datetime :
28
28
"""
29
29
For second holiday of two adjacent ones!
30
30
If holiday falls on Saturday, use following Monday instead;
@@ -39,7 +39,7 @@ def next_monday_or_tuesday(dt):
39
39
return dt
40
40
41
41
42
- def previous_friday (dt ) :
42
+ def previous_friday (dt : datetime ) -> datetime :
43
43
"""
44
44
If holiday falls on Saturday or Sunday, use previous Friday instead.
45
45
"""
@@ -50,7 +50,7 @@ def previous_friday(dt):
50
50
return dt
51
51
52
52
53
- def sunday_to_monday (dt ) :
53
+ def sunday_to_monday (dt : datetime ) -> datetime :
54
54
"""
55
55
If holiday falls on Sunday, use day thereafter (Monday) instead.
56
56
"""
@@ -59,7 +59,7 @@ def sunday_to_monday(dt):
59
59
return dt
60
60
61
61
62
- def weekend_to_monday (dt ) :
62
+ def weekend_to_monday (dt : datetime ) -> datetime :
63
63
"""
64
64
If holiday falls on Sunday or Saturday,
65
65
use day thereafter (Monday) instead.
@@ -72,7 +72,7 @@ def weekend_to_monday(dt):
72
72
return dt
73
73
74
74
75
- def nearest_workday (dt ) :
75
+ def nearest_workday (dt : datetime ) -> datetime :
76
76
"""
77
77
If holiday falls on Saturday, use day before (Friday) instead;
78
78
if holiday falls on Sunday, use day thereafter (Monday) instead.
@@ -84,7 +84,7 @@ def nearest_workday(dt):
84
84
return dt
85
85
86
86
87
- def next_workday (dt ) :
87
+ def next_workday (dt : datetime ) -> datetime :
88
88
"""
89
89
returns next weekday used for observances
90
90
"""
@@ -95,7 +95,7 @@ def next_workday(dt):
95
95
return dt
96
96
97
97
98
- def previous_workday (dt ) :
98
+ def previous_workday (dt : datetime ) -> datetime :
99
99
"""
100
100
returns previous weekday used for observances
101
101
"""
@@ -106,14 +106,14 @@ def previous_workday(dt):
106
106
return dt
107
107
108
108
109
- def before_nearest_workday (dt ) :
109
+ def before_nearest_workday (dt : datetime ) -> datetime :
110
110
"""
111
111
returns previous workday after nearest workday
112
112
"""
113
113
return previous_workday (nearest_workday (dt ))
114
114
115
115
116
- def after_nearest_workday (dt ) :
116
+ def after_nearest_workday (dt : datetime ) -> datetime :
117
117
"""
118
118
returns next workday after nearest workday
119
119
needed for Boxing day or multiple holidays in a series
@@ -428,9 +428,11 @@ def holidays(self, start=None, end=None, return_name=False):
428
428
# If we don't have a cache or the dates are outside the prior cache, we
429
429
# get them again
430
430
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 )
434
436
else :
435
437
holidays = Series (index = DatetimeIndex ([]), dtype = object )
436
438
0 commit comments