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

Remove deprecated fix-encoding-pragma, add pyupgrade #2007

Merged
merged 3 commits into from
Sep 20, 2024
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
12 changes: 8 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ repos:
- id: end-of-file-fixer
exclude_types:
- rst
- id: fix-encoding-pragma
args:
- --remove
- id: mixed-line-ending
args:
- --fix=lf
- id: trailing-whitespace
exclude_types:
- rst

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args:
- --py38-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.6.6
hooks:
- id: ruff
- id: ruff-format
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/gregorian.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13)

DAYS = set(str(d) for d in range(1, 32))
DAYS = {str(d) for d in range(1, 32)}
MONTHS = {
m: i
for i, m in enumerate(
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/thai.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __verify_calendar(calendar):
f"Unknown calendar name: {calendar}. Use `KHMER_CALENDAR` or `THAI_CALENDAR`."
)

@lru_cache()
@lru_cache
def _get_start_date(self, year: int) -> Optional[date]:
"""
Calculate the start date of that particular Thai Lunar Calendar Year.
Expand Down
8 changes: 4 additions & 4 deletions holidays/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _list_localized_entities(entity_codes: Iterable[str]) -> Dict[str, List[str]
return localized_countries


@lru_cache()
@lru_cache
def list_localized_countries(include_aliases=True) -> Dict[str, List[str]]:
"""
Get all localized countries and languages they support.
Expand All @@ -323,7 +323,7 @@ def list_localized_countries(include_aliases=True) -> Dict[str, List[str]]:
return _list_localized_entities(EntityLoader.get_country_codes(include_aliases))


@lru_cache()
@lru_cache
def list_localized_financial(include_aliases=True) -> Dict[str, List[str]]:
"""
Get all localized financial markets and languages they support.
Expand Down Expand Up @@ -358,7 +358,7 @@ def _list_supported_entities(entity_codes: Iterable[str]) -> Dict[str, List[str]
}


@lru_cache()
@lru_cache
def list_supported_countries(include_aliases=True) -> Dict[str, List[str]]:
"""
Get all supported countries and their subdivisions.
Expand All @@ -373,7 +373,7 @@ def list_supported_countries(include_aliases=True) -> Dict[str, List[str]]:
return _list_supported_entities(EntityLoader.get_country_codes(include_aliases))


@lru_cache()
@lru_cache
def list_supported_financial(include_aliases=True) -> Dict[str, List[str]]:
"""
Get all supported financial markets and their subdivisions.
Expand Down
4 changes: 2 additions & 2 deletions scripts/calendar/asian_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __init__(self) -> None:
self.LUNAR_END_DATE = (2099, 12, 30)
self.SOLAR_END_DATE = date(2100, 2, 18)

@lru_cache()
@lru_cache
def _get_leap_month(self, lunar_year: int) -> int:
"""
Return the number of the leap month if one exists in the year,
Expand All @@ -275,7 +275,7 @@ def _lunar_year_days(self, year: int) -> int:
days += day
return days

@lru_cache()
@lru_cache
def _span_days(self, year: int) -> int:
"""
Return the number of days elapsed since self.SOLAR_START_DATE to the
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def print_release_notes(self):
year=today.year,
)
)
print("\n".join((f"- {pr[0]} ({pr[1]})" for pr in self.sorted_pull_requests)))
print("\n".join(f"- {pr[0]} ({pr[1]})" for pr in self.sorted_pull_requests))

else:
print(f"No changes since {self.latest_tag_name} release.")
Expand Down
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _assertHolidays(self, instance_name, *args): # noqa: N802
self.assertEqual(
len(holidays),
len(expected_holidays),
set((dt.strftime("%Y-%m-%d"), name) for dt, name in holidays.items()).difference(
{(dt.strftime("%Y-%m-%d"), name) for dt, name in holidays.items()}.difference(
(dt, name) for dt, name in expected_holidays
),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/countries/test_finland.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_all_saints_day(self):
)

def _test_unofficial_holiday(self, name, since):
start_year, month, day = [int(part) for part in since.split("-")]
start_year, month, day = (int(part) for part in since.split("-"))
self.assertHolidayName(
name,
self.unofficial_holidays,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_supported_countries_table(self):
),
)

country_names = set(c.split("(the)")[0] for c in country_names)
country_names = {c.split("(the)")[0] for c in country_names}
supported_countries = list_supported_countries(include_aliases=False)
localized_countries = list_localized_countries(include_aliases=False)
for country_code in supported_countries:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ def test_localization(self):
self.assertFalse(
obsolete_entries,
f"The {entity_code} {language} localization contains obsolete entries: "
f"{', '.join((oe.msgid for oe in obsolete_entries))}",
f"{', '.join(oe.msgid for oe in obsolete_entries)}",
)
8 changes: 4 additions & 4 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def test_countries_imports(self):

loader_entities.add(loader_cls.__name__)

countries_entities = set(
countries_entities = {
entity[0] for entity in inspect.getmembers(countries, inspect.isclass)
)
}
self.assertEqual(
countries_entities,
loader_entities,
Expand Down Expand Up @@ -89,9 +89,9 @@ def test_financial_imports(self):

loader_entities.add(loader_cls.__name__)

financial_entities = set(
financial_entities = {
entity[0] for entity in inspect.getmembers(financial, inspect.isclass)
)
}
self.assertEqual(
financial_entities,
loader_entities,
Expand Down
Loading