Skip to content

Commit a61c147

Browse files
committed
raise TypeError in CustomBusinessDay constructor
1 parent cc4f585 commit a61c147

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4666,6 +4666,11 @@ cdef class CustomBusinessDay(BusinessDay):
46664666
offset=timedelta(0),
46674667
):
46684668
BusinessDay.__init__(self, n, normalize, offset)
4669+
if not isinstance(calendar, (None, np.busdaycalendar)):
4670+
raise TypeError(
4671+
f"Only np.busdaycalendar is supported for calendar, "
4672+
f"got {type(calendar).__name__} instead"
4673+
)
46694674
self._init_custom(weekmask, holidays, calendar)
46704675

46714676
cpdef __setstate__(self, state):
@@ -5108,8 +5113,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
51085113
warnings.warn(
51095114
f"\'{name}\' is deprecated and will be removed "
51105115
f"in a future version, please use "
5111-
f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\'"
5112-
f" instead.",
5116+
f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\' "
5117+
f"instead.",
51135118
FutureWarning,
51145119
stacklevel=find_stack_level(),
51155120
)
@@ -5122,8 +5127,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
51225127
warnings.warn(
51235128
f"\'{name}\' is deprecated and will be removed "
51245129
f"in a future version, please use "
5125-
f"\'{_name}\'"
5126-
f" instead.",
5130+
f"\'{_name}\' "
5131+
f"instead.",
51275132
FutureWarning,
51285133
stacklevel=find_stack_level(),
51295134
)

0 commit comments

Comments
 (0)