From d5c0fc71f7676bb262d0065d478f6577dae69f95 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 20 Aug 2024 22:10:24 +0200 Subject: [PATCH] Fix type hints for Python 3.8 Signed-off-by: Thomas Lauf --- src/holidata/holiday.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/holidata/holiday.py b/src/holidata/holiday.py index fb2aaad..ab6efd9 100644 --- a/src/holidata/holiday.py +++ b/src/holidata/holiday.py @@ -1,6 +1,6 @@ import datetime from dataclasses import dataclass -from typing import Iterator, Callable, Union +from typing import Iterator, Callable, Union, Dict, List import dateutil @@ -33,21 +33,21 @@ def as_dict(self) -> dict: class HolidayGenerator: def __init__(self, country_id: str, default_lang: str): - self.name_dict: dict[str, str] = {} + self.name_dict: Dict[str, str] = {} self.notes: str = "" - self.regions: list[str] = [""] + self.regions: List[str] = [""] self.flags: str = "" self.date: callable = None self.country_id: str = country_id self.default_lang: str = default_lang - self.filters: list[callable] = [] + self.filters: List[callable] = [] def with_name(self, name: str, lang: str = None) -> 'HolidayGenerator': lang = self.default_lang if lang is None else lang self.name_dict[lang] = name return self - def with_names(self, name_dict: dict[str, str]) -> 'HolidayGenerator': + def with_names(self, name_dict: Dict[str, str]) -> 'HolidayGenerator': self.name_dict = name_dict return self @@ -65,7 +65,7 @@ def with_flags(self, flags: str) -> 'HolidayGenerator': self.flags = flags return self - def in_regions(self, regions: list[str]) -> 'HolidayGenerator': + def in_regions(self, regions: List[str]) -> 'HolidayGenerator': self.regions = regions return self @@ -77,7 +77,7 @@ def annotated_with(self, note: str) -> 'HolidayGenerator': self.notes = note return self - def in_years(self, reference: list[int]) -> 'HolidayGenerator': + def in_years(self, reference: List[int]) -> 'HolidayGenerator': def reference_does_contain(year: int) -> bool: return year in reference @@ -98,7 +98,7 @@ def reference_is_greater_or_equal_to(year: int) -> bool: self.filters.append(reference_is_greater_or_equal_to) return self - def except_for(self, reference: list[int]) -> 'HolidayGenerator': + def except_for(self, reference: List[int]) -> 'HolidayGenerator': def reference_does_not_contain(year: int) -> bool: return year not in reference @@ -133,7 +133,7 @@ class Country(metaclass=PluginMount): Represents holidays of a given country """ id: str - languages: list[str] + languages: List[str] default_lang: Union[str, None] = None easter_type: str holiday_generators: list @@ -189,7 +189,7 @@ class Region: def __init__(self, id: str, country: Country): self.id: str = id self.country: Country = country - self.holiday_generators: list[HolidayGenerator] = [] + self.holiday_generators: List[HolidayGenerator] = [] def define_holiday(self) -> HolidayGenerator: generator = HolidayGenerator(self.country.id, self.country.default_lang)