Changeset - adf402442b08
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-04-21 13:51:27
brettcsmith@brettcsmith.org
books: Introduce Year type alias.

This is going to be repeated a lot as we write book-loading methods.
1 file changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/books.py
Show inline comments
...
 
@@ -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
0 comments (0 inline, 0 general)