Skip to content

Commit

Permalink
Use ruff instead of black+flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Jan 27, 2024
1 parent 4ce8146 commit 0ecd7ef
Show file tree
Hide file tree
Showing 77 changed files with 649 additions and 292 deletions.
22 changes: 6 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ repos:
exclude_types:
- rst

- repo: https://github.com/python/black
rev: 23.12.1
hooks:
- id: black
exclude: ^(docs)
language_version: python3

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-print
args: [--max-line-length=99]
exclude: ^(docs)

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand Down Expand Up @@ -63,6 +47,12 @@ repos:
- rstcheck
- sphinx

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: '1.3.1'
hooks:
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/albania.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@


class Albania(
ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
ObservedHolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
References:
Expand Down
6 changes: 2 additions & 4 deletions holidays/countries/angola.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,9 @@ def _populate_public_holidays(self):
tr("Dia de Natal e da Família")
if self._year >= 2011
else (
# Christmas Day.
tr("Dia do Natal")
tr("Dia do Natal") # Christmas Day.
if self._year >= 1996
# Family Day.
else tr("Dia da Família")
else tr("Dia da Família") # Family Day.
)
)
dt = self._add_christmas_day(name)
Expand Down
6 changes: 2 additions & 4 deletions holidays/countries/aruba.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ def _populate_public_holidays(self):
tr("Dia di Rey")
if self._year >= 2021
else (
# King's Day.
tr("Aña di Rey")
tr("Aña di Rey") # King's Day.
if self._year >= 2014
# Queen's Day.
else tr("Aña di La Reina")
else tr("Aña di La Reina") # Queen's Day.
)
)
if self._year >= 2014:
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/belize.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def _populate_public_holidays(self):
# Indigenous Peoples' Resistance Day / Pan American Day.
name = "Indigenous Peoples' Resistance Day" if self._year >= 2021 else "Pan American Day"
self._move_holiday(
self._add_columbus_day(name), rule=TUE_WED_THU_TO_PREV_MON + FRI_SUN_TO_NEXT_MON
self._add_columbus_day(name),
rule=TUE_WED_THU_TO_PREV_MON + FRI_SUN_TO_NEXT_MON,
)

# Garifuna Settlement Day.
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/bulgaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def _populate_public_holidays(self):

if self.observed:
self._populate_observed(
dts_observed, excluded_names={self.tr("Велика събота"), self.tr("Великден")}
dts_observed,
excluded_names={self.tr("Велика събота"), self.tr("Великден")},
)

def _populate_school_holidays(self):
Expand Down
8 changes: 3 additions & 5 deletions holidays/countries/cambodia.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,9 @@ def _populate_public_holidays(self):

if self._year >= 1994:
self._add_holiday_jun_18(
# Birthday of Her Majesty the Queen-Mother NORODOM MONINEATH SIHANOUK of Cambodia
tr(
"ព្រះរាជពិធីបុណ្យចម្រើនព្រះជន្ម សម្តេចព្រះមហាក្សត្រី ព្រះវររាជមាតា នរោត្តម "
"មុនិនាថ សីហនុ"
),
# Birthday of Her Majesty the Queen-Mother
# NORODOM MONINEATH SIHANOUK of Cambodia
tr("ព្រះរាជពិធីបុណ្យចម្រើនព្រះជន្ម សម្តេចព្រះមហាក្សត្រី ព្រះវររាជមាតា នរោត្តម មុនិនាថ សីហនុ"),
)

# ទិវាប្រកាសរដ្ឋធម្មនុញ្ញ
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/cameroon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@


class Cameroon(
ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
ObservedHolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
References:
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/chad.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@


class Chad(
ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
ObservedHolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
References:
Expand Down
12 changes: 10 additions & 2 deletions holidays/countries/china.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,15 @@ class ChinaStaticHolidays:
2012: (JUN, 22, dragon_boat_festival), # observed from Jun 23
2015: (OCT, 6, mid_autumn_festival), # observed from Sep 27
2020: (
(JAN, 30, chinese_new_year), # Spring Festival (extended due to Covid-19 decree)
(OCT, 6, mid_autumn_festival), # observed from Oct 1, overlap with National Day
(
JAN,
30,
chinese_new_year,
), # Spring Festival (extended due to Covid-19 decree)
(
OCT,
6,
mid_autumn_festival,
), # observed from Oct 1, overlap with National Day
),
}
3 changes: 2 additions & 1 deletion holidays/countries/hongkong.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def _populate_public_holidays(self):
self._add_mid_autumn_festival(name)
else:
self._add_holiday(
f"The second day of the {name} (Monday)", mid_autumn_date + td(days=+2)
f"The second day of the {name} (Monday)",
mid_autumn_date + td(days=+2),
)
else:
self._add_mid_autumn_festival_day_two(f"The day following the {name}")
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/hungary.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ def _populate_public_holidays(self):
# Bread Day.
tr("A kenyér ünnepe")
if 1950 <= self._year <= 1989
else
# State Foundation Day.
tr("Az államalapítás ünnepe"),
else tr("Az államalapítás ünnepe"),
)

if self._year >= 1991:
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/ireland.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def _populate_public_holidays(self):

# St. Stephen's Day.
self._add_observed(
self._add_christmas_day_two("St. Stephen's Day"), rule=SAT_SUN_TO_NEXT_MON_TUE
self._add_christmas_day_two("St. Stephen's Day"),
rule=SAT_SUN_TO_NEXT_MON_TUE,
)


Expand Down
13 changes: 12 additions & 1 deletion holidays/countries/malaysia.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,18 @@ def _populate_public_holidays(self):
dts_observed.update(self._add_ramadan_beginning_day("Beginning of Ramadan"))

# Nuzul Al-Quran Day.
if self.subdiv in {"KTN", "KUL", "LBN", "PHG", "PJY", "PLS", "PNG", "PRK", "SGR", "TRG"}:
if self.subdiv in {
"KTN",
"KUL",
"LBN",
"PHG",
"PJY",
"PLS",
"PNG",
"PRK",
"SGR",
"TRG",
}:
dts_observed.update(self._add_nuzul_al_quran_day("Nuzul Al-Quran Day"))

# Thaipusam.
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/marshall_islands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def __init__(self, *args, **kwargs):
def _populate_public_holidays(self):
if self._year <= 2019:
warnings.warn(
"Years before 2020 are not available for the Marshall Islands (MH).", Warning
"Years before 2020 are not available for the Marshall Islands (MH).",
Warning,
)

# New Year's Day
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/new_zealand.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def _populate_public_holidays(self):
# New Year's Day
self._add_observed(self._add_new_years_day("New Year's Day"), rule=SAT_SUN_TO_NEXT_MON_TUE)
self._add_observed(
self._add_new_years_day_two("Day after New Year's Day"), rule=SAT_SUN_TO_NEXT_MON_TUE
self._add_new_years_day_two("Day after New Year's Day"),
rule=SAT_SUN_TO_NEXT_MON_TUE,
)

# Waitangi Day
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/nigeria.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@


class Nigeria(
ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
ObservedHolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
https://en.wikipedia.org/wiki/Public_holidays_in_Nigeria
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/philippines.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@


class Philippines(
HolidayBase, ChineseCalendarHolidays, ChristianHolidays, InternationalHolidays, IslamicHolidays
HolidayBase,
ChineseCalendarHolidays,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
):
"""
Philippines holidays.
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/south_korea.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def _populate_observed(self, dts: Set[date], three_day_holidays: Dict[date, str]
if not self._is_observed(dt):
continue
dt_observed = self._get_observed_date(
dt, SUN_TO_NEXT_WORKDAY if dt in three_day_holidays else SAT_SUN_TO_NEXT_WORKDAY
dt,
SUN_TO_NEXT_WORKDAY if dt in three_day_holidays else SAT_SUN_TO_NEXT_WORKDAY,
)
if dt_observed != dt or len(self.get_list(dt)) > 1:
if dt_observed == dt:
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/spain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@


class Spain(
ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
ObservedHolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
Holidays checked with official sources for 2010-2023 only.
Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/tanzania.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@


class Tanzania(
HolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
HolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
References:
Expand Down
21 changes: 5 additions & 16 deletions holidays/countries/thailand.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ def _populate_public_holidays(self):
elif self._year >= 2019:
# Anniversary for the Death of King Bhumibol Adulyadej the Great.
k_bhumibol_memorial = tr(
"วันคล้ายวันสวรรคตพระบาทสมเด็จพระบรมชนกาธิเบศร "
"มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
"วันคล้ายวันสวรรคตพระบาทสมเด็จพระบรมชนกาธิเบศร มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
)
else:
# Anniversary for the Death of King Bhumibol Adulyadej.
Expand Down Expand Up @@ -375,10 +374,7 @@ def _populate_public_holidays(self):
elif self._year >= 2016:
k_bhumibol_bday = (
# HM King Bhumibol Adulyadej Birthday Anniversary.
tr(
"วันคล้ายวันเฉลิมพระชนมพรรษา"
"พระบาทสมเด็จพระปรมินทรมหาภูมิพลอดุลยเดช บรมนาถบพิตร"
)
tr("วันคล้ายวันเฉลิมพระชนมพรรษาพระบาทสมเด็จพระปรมินทรมหาภูมิพลอดุลยเดช บรมนาถบพิตร")
)
else:
k_bhumibol_bday = (
Expand Down Expand Up @@ -504,10 +500,7 @@ def _populate_bank_holidays(self):
if self._year <= 2021:
self._add_holiday_apr_1(
# Additional Closing Day for Bank for Agriculture and Agricultural Cooperatives
tr(
"วันหยุดเพิ่มเติมสำหรับการปิดบัญชีประจำปีของ"
"ธนาคารเพื่อการเกษตรและสหกรณ์การเกษตร"
),
tr("วันหยุดเพิ่มเติมสำหรับการปิดบัญชีประจำปีของธนาคารเพื่อการเกษตรและสหกรณ์การเกษตร"),
)

# วันหยุดภาคครึ่งปีของสถาบันการเงินและสถาบันการเงินเฉพาะกิจ
Expand Down Expand Up @@ -728,13 +721,9 @@ class ThailandStaticHolidays:
# Day of Mourning for HM King Bhumibol Adulyadej.
rama_ix_mourning = tr("วันหยุดพิเศษ (ร่วมถวายอาลัย ส่งดวงพระวิญญาณพระบรมศพ)")
# HM King Bhumibol Adulyadej's Royal Cremation Ceremony.
rama_ix_cremation = tr(
"วันพระราชพิธีถวายพระเพลิงพระบรมศพพระบาทสมเด็จพระปรมินทรมหาภูมิพลอดุลยเดช"
)
rama_ix_cremation = tr("วันพระราชพิธีถวายพระเพลิงพระบรมศพพระบาทสมเด็จพระปรมินทรมหาภูมิพลอดุลยเดช")
# HM King Maha Vajiralongkorn's Coronation Celebrations.
rama_x_coronation_celebrations = tr(
"พระราชพิธีบรมราชาภิเษก พระบาทสมเด็จพระวชิรเกล้าเจ้าอยู่หัว"
)
rama_x_coronation_celebrations = tr("พระราชพิธีบรมราชาภิเษก พระบาทสมเด็จพระวชิรเกล้าเจ้าอยู่หัว")
# Songkran Festival.
songkran_festival = tr("วันสงกรานต์")

Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/timor_leste.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@


class TimorLeste(
HolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays, StaticHolidays
HolidayBase,
ChristianHolidays,
InternationalHolidays,
IslamicHolidays,
StaticHolidays,
):
"""
References:
Expand Down
14 changes: 12 additions & 2 deletions holidays/countries/united_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,22 @@ def _add_christmas_eve_holiday(self):
# If on Saturday or Sunday, observed on Friday
name = "Christmas Eve"
self._add_observed(
self._add_christmas_eve(name), name=name, rule=FRI_TO_PREV_THU + SAT_SUN_TO_PREV_FRI
self._add_christmas_eve(name),
name=name,
rule=FRI_TO_PREV_THU + SAT_SUN_TO_PREV_FRI,
)

def _populate_subdiv_holidays(self):
# Martin Luther King Jr. Day
if self._year >= 1986 and self.subdiv not in {"AL", "AR", "AZ", "GA", "ID", "MS", "NH"}:
if self._year >= 1986 and self.subdiv not in {
"AL",
"AR",
"AZ",
"GA",
"ID",
"MS",
"NH",
}:
self._add_holiday_3rd_mon_of_jan("Martin Luther King Jr. Day")

# Washington's Birthday
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/vanuatu.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def _populate_public_holidays(self):

# Family Day.
self._add_observed(
self._add_christmas_day_two("Family Day"), rule=SUN_TO_NEXT_MON + MON_TO_NEXT_TUE
self._add_christmas_day_two("Family Day"),
rule=SUN_TO_NEXT_MON + MON_TO_NEXT_TUE,
)


Expand Down
6 changes: 5 additions & 1 deletion holidays/countries/zambia.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ class ZambiaStaticHolidays:
special_public_holidays = {
2016: (
(AUG, 11, "General elections and referendum"),
(SEP, 13, "Inauguration ceremony of President-elect and Vice President-elect"),
(
SEP,
13,
"Inauguration ceremony of President-elect and Vice President-elect",
),
),
2018: (
(MAR, 9, "Public holiday"),
Expand Down
Loading

0 comments on commit 0ecd7ef

Please sign in to comment.