Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize .py files formatting #1332

Merged
merged 2 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions holidays/calendars/buddhist.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ class _BuddhistLunisolar:

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(
self,
f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}",
{},
)
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

Expand Down
6 changes: 1 addition & 5 deletions holidays/calendars/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,7 @@ class _ChineseLunisolar:

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(
self,
f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}",
{},
)
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

Expand Down
6 changes: 1 addition & 5 deletions holidays/calendars/hindu.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ class _HinduLunisolar:

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(
self,
f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}",
{},
)
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

Expand Down
6 changes: 1 addition & 5 deletions holidays/calendars/islamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,11 +1436,7 @@ class _IslamicLunar:

def _get_holiday(self, holiday: str, year: int) -> Iterable[Tuple[date, bool]]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(
self,
f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}",
{},
)
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
for year in (year - 1, year):
for dt in _normalize_tuple(exact_dates.get(year, estimated_dates.get(year, ()))):
yield date(year, *dt), year not in exact_dates
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/albania.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Albania(HolidayBase, ChristianHolidays, InternationalHolidays, IslamicHoli

country = "AL"
special_holidays = {
2022: ((MAR, 21, "Public Holiday"),),
2022: (MAR, 21, "Public Holiday"),
}

def __init__(self, *args, **kwargs):
Expand Down
7 changes: 2 additions & 5 deletions holidays/countries/argentina.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def add_movable_holiday(dt: date, name: str) -> None:

if year >= 2006:
self._add_holiday(
tr("Día Nacional de la Memoria por la Verdad y la Justicia"),
MAR,
24,
tr("Día Nacional de la Memoria por la Verdad y la Justicia"), MAR, 24
)

# Veterans Day and the Fallen in the Malvinas War.
Expand Down Expand Up @@ -304,8 +302,7 @@ def add_movable_holiday(dt: date, name: str) -> None:
self._add_columbus_day(tr("Día de la Raza"))
elif year >= 2010:
add_movable_holiday(
date(year, OCT, 12),
tr("Día del Respeto a la Diversidad Cultural"),
date(year, OCT, 12), tr("Día del Respeto a la Diversidad Cultural")
)

# National Sovereignty Day.
Expand Down
40 changes: 9 additions & 31 deletions holidays/countries/australia.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ class Australia(HolidayBase, ChristianHolidays, InternationalHolidays):

country = "AU"
special_holidays = {
2022: (
(
SEP,
22,
"National Day of Mourning for Queen Elizabeth II",
),
),
2022: (SEP, 22, "National Day of Mourning for Queen Elizabeth II"),
}
subdivisions = ("ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA")

Expand All @@ -46,8 +40,7 @@ def _add_observed(self, dt: date, include_sat: bool = True, days: int = +1) -> N
return None
if self._is_sunday(dt) or (include_sat and self._is_saturday(dt)):
self._add_holiday(
"%s (Observed)" % self[dt],
dt + td(days=+2 if self._is_saturday(dt) else days),
"%s (Observed)" % self[dt], dt + td(days=+2 if self._is_saturday(dt) else days)
)

def _populate(self, year):
Expand Down Expand Up @@ -167,8 +160,7 @@ def _add_subdiv_act_holidays(self):
# Reconciliation Day
if self._year >= 2018:
self._add_holiday(
"Reconciliation Day",
_get_nth_weekday_from(1, MON, date(self._year, MAY, 27)),
"Reconciliation Day", _get_nth_weekday_from(1, MON, date(self._year, MAY, 27))
)

def _add_subdiv_nsw_holidays(self):
Expand All @@ -184,10 +176,7 @@ def _add_subdiv_nsw_holidays(self):

# Bank Holiday
if self._year >= 1912:
self._add_holiday(
"Bank Holiday",
_get_nth_weekday_of_month(1, MON, AUG, self._year),
)
self._add_holiday("Bank Holiday", _get_nth_weekday_of_month(1, MON, AUG, self._year))

def _add_subdiv_nt_holidays(self):
# Easter
Expand Down Expand Up @@ -243,8 +232,7 @@ def _add_subdiv_qld_holidays(self):
2021: date(2021, OCT, 29),
}
dt = ekka_dates.get(
self._year,
_get_nth_weekday_from(1, FRI, date(self._year, AUG, 5)) + td(days=+5),
self._year, _get_nth_weekday_from(1, FRI, date(self._year, AUG, 5)) + td(days=+5)
)
self._add_holiday("The Royal Queensland Show", dt)

Expand All @@ -270,10 +258,7 @@ def _add_subdiv_sa_holidays(self):

def _add_subdiv_tas_holidays(self):
# Labour Day
self._add_holiday(
"Eight Hours Day",
_get_nth_weekday_of_month(2, MON, MAR, self._year),
)
self._add_holiday("Eight Hours Day", _get_nth_weekday_of_month(2, MON, MAR, self._year))

# Sovereign's Birthday
self._add_sovereign_birthday(_get_nth_weekday_of_month(2, MON, JUN, self._year))
Expand All @@ -284,19 +269,13 @@ def _add_subdiv_vic_holidays(self):
self._add_easter_sunday("Easter Sunday")

# Labour Day
self._add_holiday(
"Labour Day",
_get_nth_weekday_of_month(2, MON, MAR, self._year),
)
self._add_holiday("Labour Day", _get_nth_weekday_of_month(2, MON, MAR, self._year))

# Sovereign's Birthday
self._add_sovereign_birthday(_get_nth_weekday_of_month(2, MON, JUN, self._year))

# Melbourne Cup
self._add_holiday(
"Melbourne Cup",
_get_nth_weekday_of_month(1, TUE, NOV, self._year),
)
self._add_holiday("Melbourne Cup", _get_nth_weekday_of_month(1, TUE, NOV, self._year))

if self._year >= 2015:
# Grand Final Day
Expand All @@ -308,8 +287,7 @@ def _add_subdiv_vic_holidays(self):
2022: date(2022, SEP, 23),
}
dt = grand_final_dates.get(
self._year,
_get_nth_weekday_from(1, FRI, date(self._year, SEP, 24)),
self._year, _get_nth_weekday_from(1, FRI, date(self._year, SEP, 24))
)
self._add_holiday("Grand Final Day", dt)

Expand Down
9 changes: 2 additions & 7 deletions holidays/countries/azerbaijan.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ def _add_observed(dt: date, name: str = None):
# Republic Day
if year >= 1992:
observed_dates.add(
self._add_holiday(
"Independence Day" if year >= 2021 else "Republic Day",
MAY,
28,
)
self._add_holiday("Independence Day" if year >= 2021 else "Republic Day", MAY, 28)
)

# National Salvation Day
Expand Down Expand Up @@ -142,8 +138,7 @@ def _add_observed(dt: date, name: str = None):
if year in special_dates_obs:
hol_dates.add(
self._add_holiday(
"Gurban Bayrami* (*estimated) (Observed)",
*special_dates_obs[year],
"Gurban Bayrami* (*estimated) (Observed)", *special_dates_obs[year]
)
)

Expand Down
11 changes: 2 additions & 9 deletions holidays/countries/belarus.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,13 @@ def _populate(self, year):
self._add_world_war_two_victory_day(tr("Дзень Перамогі"))

# Independence Day.
self._add_holiday(
tr("Дзень Незалежнасці Рэспублікі Беларусь (Дзень Рэспублікі)"),
JUL,
3,
)
self._add_holiday(tr("Дзень Незалежнасці Рэспублікі Беларусь (Дзень Рэспублікі)"), JUL, 3)

# October Revolution Day.
self._add_holiday(tr("Дзень Кастрычніцкай рэвалюцыі"), NOV, 7)

# Catholic Christmas Day.
self._add_christmas_day(
tr("Нараджэнне Хрыстова (каталіцкае Раство)"),
GREGORIAN_CALENDAR,
)
self._add_christmas_day(tr("Нараджэнне Хрыстова (каталіцкае Раство)"), GREGORIAN_CALENDAR)


class BY(Belarus):
Expand Down
4 changes: 1 addition & 3 deletions holidays/countries/bosnia_and_herzegovina.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ def _add_subdiv_rs_holidays(self):

# Dayton Agreement Day
self._add_holiday(
("Dan uspostave Opšteg okvirnog sporazuma za mir u Bosni i Hercegovini"),
NOV,
21,
("Dan uspostave Opšteg okvirnog sporazuma za mir u Bosni i Hercegovini"), NOV, 21
)

# Catholic Good Friday
Expand Down
60 changes: 16 additions & 44 deletions holidays/countries/brazil.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,8 @@ def _populate(self, year):
# Abolition of slavery in Brazil.
self._add_holiday("Abolição da escravidão no Brasil", MAY, 13)

self._add_holiday(
# Freedom and Independence of American Peoples.
"Liberdade e Independência dos Povos Americanos",
JUL,
14,
)
# Freedom and Independence of American Peoples.
self._add_holiday("Liberdade e Independência dos Povos Americanos", JUL, 14)

# Independence Day.
self._add_holiday("Independência do Brasil", SEP, 7)
Expand Down Expand Up @@ -159,11 +155,8 @@ def get_movable_acre(*args) -> date:
self._add_holiday("Dia do Evangélico", get_movable_acre(JAN, 23))

if self._year >= 2002:
self._add_holiday(
# International Women's Day.
"Dia Internacional da Mulher",
get_movable_acre(MAR, 8),
)
# International Women's Day.
self._add_holiday("Dia Internacional da Mulher", get_movable_acre(MAR, 8))

# Founding of Acre.
self._add_holiday("Aniversário do Acre", JUN, 15)
Expand All @@ -172,11 +165,8 @@ def get_movable_acre(*args) -> date:
# Amazonia Day.
self._add_holiday("Dia da Amazônia", get_movable_acre(SEP, 5))

self._add_holiday(
# Signing of the Petropolis Treaty.
"Assinatura do Tratado de Petrópolis",
get_movable_acre(NOV, 17),
)
# Signing of the Petropolis Treaty.
self._add_holiday("Assinatura do Tratado de Petrópolis", get_movable_acre(NOV, 17))

def _add_subdiv_al_holidays(self):
# Saint John's Day.
Expand All @@ -195,12 +185,8 @@ def _add_subdiv_al_holidays(self):
self._add_holiday("Dia do Evangélico", NOV, 30)

def _add_subdiv_am_holidays(self):
self._add_holiday(
# Elevation of Amazonas to province.
"Elevação do Amazonas à categoria de província",
SEP,
5,
)
# Elevation of Amazonas to province.
self._add_holiday("Elevação do Amazonas à categoria de província", SEP, 5)

if self._year >= 2010:
self._add_holiday("Consciência Negra", NOV, 20)
Expand Down Expand Up @@ -242,11 +228,8 @@ def _add_subdiv_df_holidays(self):

def _add_subdiv_es_holidays(self):
if self._year >= 2020:
self._add_holiday(
# Our Lady of Penha.
"Nossa Senhora da Penha",
self._easter_sunday + td(days=+8),
)
# Our Lady of Penha.
self._add_holiday("Nossa Senhora da Penha", self._easter_sunday + td(days=+8))

def _add_subdiv_go_holidays(self):
# Foundation of Goiás city.
Expand All @@ -256,12 +239,8 @@ def _add_subdiv_go_holidays(self):
self._add_holiday("Pedra fundamental de Goiânia", OCT, 24)

def _add_subdiv_ma_holidays(self):
self._add_holiday(
# Maranhão joining to independence of Brazil.
"Adesão do Maranhão à independência do Brasil",
JUL,
28,
)
# Maranhão joining to independence of Brazil.
self._add_holiday("Adesão do Maranhão à independência do Brasil", JUL, 28)

def _add_subdiv_mg_holidays(self):
# Tiradentes' Execution.
Expand All @@ -276,12 +255,8 @@ def _add_subdiv_mt_holidays(self):
self._add_holiday("Consciência Negra", NOV, 20)

def _add_subdiv_pa_holidays(self):
self._add_holiday(
# Grão-Pará joining to independence of Brazil.
"Adesão do Grão-Pará à independência do Brasil",
AUG,
15,
)
# Grão-Pará joining to independence of Brazil.
self._add_holiday("Adesão do Grão-Pará à independência do Brasil", AUG, 15)

def _add_subdiv_pb_holidays(self):
# State Founding Day.
Expand Down Expand Up @@ -338,11 +313,8 @@ def _add_subdiv_sc_holidays(self):
dt = date(self._year, AUG, 11)
if self._year >= 2005:
dt = _get_nth_weekday_from(1, SUN, dt)
self._add_holiday(
# Santa Catarina State Day.
"Dia do Estado de Santa Catarina",
dt,
)
# Santa Catarina State Day.
self._add_holiday("Dia do Estado de Santa Catarina", dt)

dt = date(self._year, NOV, 25)
if 1999 <= self._year != 2004:
Expand Down
7 changes: 1 addition & 6 deletions holidays/countries/brunei.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ def _add_observed(dt: date) -> None:
if obs_date:
self._add_islamic_calendar_holiday(
self.tr("%s - Diperhatikan") % self[hol_date],
(
(
obs_date,
self._year not in BruneiIslamicCalendar.EID_AL_FITR_DATES,
),
),
((obs_date, self._year not in BruneiIslamicCalendar.EID_AL_FITR_DATES),),
)

# Hari Raya Aidil Adha
Expand Down
6 changes: 1 addition & 5 deletions holidays/countries/bulgaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def _populate(self, year):
self._add_holiday(tr("Ден на Освобождението на България от османско иго"), MAR, 3)

# International Workers' Day.
self._add_holiday(
tr("Ден на труда и на международната работническа солидарност"),
MAY,
1,
)
self._add_holiday(tr("Ден на труда и на международната работническа солидарност"), MAY, 1)

# Saint George's Day.
self._add_holiday(tr("Гергьовден, Ден на храбростта и Българската армия"), MAY, 6)
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/burundi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def _add_holiday(self, *args) -> Optional[date]:
dt = super()._add_holiday(*args)
if self.observed and dt and self._is_sunday(dt):
super()._add_holiday(
"%s (Observed)" % self[dt], # type: ignore[index]
dt + td(days=+1), # type: ignore[operator]
"%s (Observed)" % self[dt], dt + td(days=+1) # type: ignore[index, operator]
)
return dt

Expand Down
Loading