Skip to content

Commit

Permalink
Satisfy mypy requirements (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r authored Oct 17, 2024
1 parent bb25790 commit 6750bf1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
exclude: ^(docs)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.12.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
16 changes: 10 additions & 6 deletions holidays/groups/buddhist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, cls=None, show_estimated=False) -> None:
self._buddhist_calendar_show_estimated = show_estimated

def _add_buddhist_calendar_holiday(
self, name: str, dt_estimated: tuple[date, bool]
self, name: str, dt_estimated: tuple[Optional[date], bool]
) -> Optional[date]:
"""
Add Buddhist calendar holiday.
Expand All @@ -37,11 +37,15 @@ def _add_buddhist_calendar_holiday(
estimated_label = getattr(self, "estimated_label", "%s (estimated)")
dt, is_estimated = dt_estimated

return self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._buddhist_calendar_show_estimated
else name,
dt,
return (
self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._buddhist_calendar_show_estimated
else name,
dt,
)
if dt
else None
)

def _add_vesak(self, name) -> Optional[date]:
Expand Down
18 changes: 11 additions & 7 deletions holidays/groups/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _mid_autumn_festival(self):
return self._chinese_calendar.mid_autumn_date(self._year)[0]

def _add_chinese_calendar_holiday(
self, name: str, dt_estimated: tuple[date, bool], days_delta: int = 0
self, name: str, dt_estimated: tuple[Optional[date], bool], days_delta: int = 0
) -> Optional[date]:
"""
Add Chinese calendar holiday.
Expand All @@ -59,14 +59,18 @@ def _add_chinese_calendar_holiday(
estimated_label = getattr(self, "estimated_label", "%s (estimated)")
dt, is_estimated = dt_estimated

if days_delta != 0:
if days_delta and dt:
dt = _timedelta(dt, days_delta)

return self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._chinese_calendar_show_estimated
else name,
dt,
return (
self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._chinese_calendar_show_estimated
else name,
dt,
)
if dt
else None
)

def _add_chinese_birthday_of_buddha(self, name) -> Optional[date]:
Expand Down
16 changes: 10 additions & 6 deletions holidays/groups/hindu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, cls=None, show_estimated=False) -> None:
self._hindu_calendar_show_estimated = show_estimated

def _add_hindu_calendar_holiday(
self, name: str, dt_estimated: tuple[date, bool]
self, name: str, dt_estimated: tuple[Optional[date], bool]
) -> Optional[date]:
"""
Add Hindu calendar holiday.
Expand All @@ -37,11 +37,15 @@ def _add_hindu_calendar_holiday(
estimated_label = getattr(self, "estimated_label", "%s (estimated)")
dt, is_estimated = dt_estimated

return self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._hindu_calendar_show_estimated
else name,
dt,
return (
self._add_holiday(
self.tr(estimated_label) % self.tr(name)
if is_estimated and self._hindu_calendar_show_estimated
else name,
dt,
)
if dt
else None
)

def _add_diwali(self, name) -> Optional[date]:
Expand Down

0 comments on commit 6750bf1

Please sign in to comment.