diff --git a/conservancy_beancount/plugin/core.py b/conservancy_beancount/plugin/core.py index 39dc7e2..f2fb69b 100644 --- a/conservancy_beancount/plugin/core.py +++ b/conservancy_beancount/plugin/core.py @@ -23,6 +23,7 @@ from .. import errors as errormod from typing import ( Any, + Dict, FrozenSet, Generic, Iterable, @@ -113,7 +114,7 @@ class MetadataEnum: def __init__(self, key: MetaKey, standard_values: Iterable[MetaValueEnum], - aliases_map: Mapping[MetaValueEnum, MetaValueEnum], + aliases_map: Optional[Mapping[MetaValueEnum, MetaValueEnum]]=None, ) -> None: """Specify allowed values and aliases for this metadata. @@ -129,9 +130,9 @@ class MetadataEnum: """ self.key = key self._stdvalues = frozenset(standard_values) - self._aliases = dict(aliases_map) + self._aliases: Dict[MetaValueEnum, MetaValueEnum] = dict(aliases_map or ()) + assert self._stdvalues.issuperset(self._aliases.values()) self._aliases.update((v, v) for v in standard_values) - assert self._stdvalues == set(self._aliases.values()) def __repr__(self) -> str: return "{}<{}>".format(type(self).__name__, self.key) diff --git a/conservancy_beancount/plugin/meta_tax_implication.py b/conservancy_beancount/plugin/meta_tax_implication.py index 3f0a61a..2716dd1 100644 --- a/conservancy_beancount/plugin/meta_tax_implication.py +++ b/conservancy_beancount/plugin/meta_tax_implication.py @@ -43,7 +43,7 @@ class MetaTaxImplication(core._NormalizePostingMetadataHook): 'USA-Corporation', 'USA-LLC-No-1099', 'W2', - ], {}) + ]) def _run_on_post(self, txn: Transaction, post: data.Posting) -> bool: return bool(