Skip to content

Commit

Permalink
Fix type hints for Python 3.8
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Lauf <[email protected]>
  • Loading branch information
lauft committed Aug 20, 2024
1 parent 4925016 commit d5c0fc7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/holidata/holiday.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d5c0fc7

Please sign in to comment.