Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class PandasExtensionDtype(ExtensionDtype):
# problem dealing with multiple inheritance from PandasExtensionDtype
# and ExtensionDtype's @properties in the subclasses below. The kind and
# type variables in those subclasses are explicitly typed below.
subdtype = None
subdtype: DtypeObj | None = None
str: str_type
num = 100
shape: tuple[int, ...] = ()
Expand Down Expand Up @@ -1604,7 +1604,7 @@ class BaseMaskedDtype(ExtensionDtype):
Base class for dtypes for BaseMaskedArray subclasses.
"""

base = None
base: DtypeObj | None = None
type: type
_internal_fill_value: Scalar

Expand Down
34 changes: 23 additions & 11 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
datetime,
timedelta,
)
from typing import TYPE_CHECKING
from typing import (
TYPE_CHECKING,
Literal,
overload,
)
import warnings

from dateutil.relativedelta import (
Expand Down Expand Up @@ -281,6 +285,17 @@ def __repr__(self) -> str:
repr = f"Holiday: {self.name} ({info})"
return repr

@overload
def dates(self, start_date, end_date, return_name: Literal[True]) -> Series: ...

@overload
def dates(
self, start_date, end_date, return_name: Literal[False]
) -> DatetimeIndex: ...

@overload
def dates(self, start_date, end_date) -> DatetimeIndex: ...

def dates(
self, start_date, end_date, return_name: bool = False
) -> Series | DatetimeIndex:
Expand Down Expand Up @@ -411,7 +426,7 @@ def _apply_rule(self, dates: DatetimeIndex) -> DatetimeIndex:
return dates


holiday_calendars = {}
holiday_calendars: dict[str, type[AbstractHolidayCalendar]] = {}


def register(cls) -> None:
Expand Down Expand Up @@ -449,7 +464,7 @@ class AbstractHolidayCalendar(metaclass=HolidayCalendarMetaClass):
rules: list[Holiday] = []
start_date = Timestamp(datetime(1970, 1, 1))
end_date = Timestamp(datetime(2200, 12, 31))
_cache = None
_cache: tuple[Timestamp, Timestamp, Series] | None = None

def __init__(self, name: str = "", rules=None) -> None:
"""
Expand Down Expand Up @@ -478,7 +493,9 @@ def rule_from_name(self, name: str) -> Holiday | None:

return None

def holidays(self, start=None, end=None, return_name: bool = False):
def holidays(
self, start=None, end=None, return_name: bool = False
) -> DatetimeIndex | Series:
"""
Returns a curve with holidays between start_date and end_date

Expand Down Expand Up @@ -515,14 +532,9 @@ def holidays(self, start=None, end=None, return_name: bool = False):
rule.dates(start, end, return_name=True) for rule in self.rules
]
if pre_holidays:
# error: Argument 1 to "concat" has incompatible type
# "List[Union[Series, DatetimeIndex]]"; expected
# "Union[Iterable[DataFrame], Mapping[<nothing>, DataFrame]]"
holidays = concat(pre_holidays) # type: ignore[arg-type]
holidays = concat(pre_holidays)
else:
# error: Incompatible types in assignment (expression has type
# "Series", variable has type "DataFrame")
holidays = Series(index=DatetimeIndex([]), dtype=object) # type: ignore[assignment]
holidays = Series(index=DatetimeIndex([]), dtype=object)

self._cache = (start, end, holidays.sort_index())

Expand Down
Loading