books: Introduce Year type alias.

This is going to be repeated a lot as we write book-loading methods.
This commit is contained in:
Brett Smith 2020-04-21 09:51:27 -04:00
parent 51137815d3
commit adf402442b

View file

@ -23,6 +23,8 @@ from typing import (
Union,
)
Year = Union[int, datetime.date]
class FiscalYear(NamedTuple):
month: int = 3
day: int = 1
@ -35,10 +37,7 @@ class FiscalYear(NamedTuple):
else:
return date.year
def range(self,
from_fy: Union[int, datetime.date],
to_fy: Union[int, datetime.date, None]=None,
) -> Iterable[int]:
def range(self, from_fy: Year, to_fy: Optional[Year]=None) -> Iterable[int]:
"""Return a range of fiscal years
Both arguments can be either a year (represented as an integer) or a