diff --git a/conservancy_beancount/data.py b/conservancy_beancount/data.py index 0ce0282457b0ac02e8b196ac58badf7b66af8bf2..ff865242e24d4d1ae76669cb047228cc84c50d6f 100644 --- a/conservancy_beancount/data.py +++ b/conservancy_beancount/data.py @@ -293,13 +293,13 @@ class Posting(BasePosting): ) @classmethod - def from_txn(cls, txn: Transaction) -> Iterable['Posting']: + def from_txn(cls, txn: Transaction) -> Iterator['Posting']: """Yield an enhanced Posting object for every posting in the transaction""" for index, post in enumerate(txn.postings): yield cls.from_beancount(txn, index, post) @classmethod - def from_entries(cls, entries: Iterable[Directive]) -> Iterable['Posting']: + def from_entries(cls, entries: Iterable[Directive]) -> Iterator['Posting']: """Yield an enhanced Posting object for every posting in these entries""" for entry in entries: # Because Beancount's own Transaction class isn't type-checkable, diff --git a/conservancy_beancount/plugin/__init__.py b/conservancy_beancount/plugin/__init__.py index 97578895ced3ab930b633df1b1ccec707a567616..120c63ee8f9e8f6e67b1cefe390f3fd322c1e450 100644 --- a/conservancy_beancount/plugin/__init__.py +++ b/conservancy_beancount/plugin/__init__.py @@ -22,7 +22,7 @@ from typing import ( AbstractSet, Any, Dict, - Iterable, + Iterator, List, Optional, Set, @@ -93,7 +93,7 @@ class HookRegistry: for mod_name, hook_names in self.INCLUDED_HOOKS.items(): self.import_hooks(mod_name, *(hook_names or []), package=self.__module__) - def group_by_directive(self, config_str: str='') -> Iterable[Tuple[HookName, Type[Hook]]]: + def group_by_directive(self, config_str: str='') -> Iterator[Tuple[HookName, Type[Hook]]]: config_str = config_str.strip() if not config_str: config_str = 'all' diff --git a/conservancy_beancount/plugin/core.py b/conservancy_beancount/plugin/core.py index c625ec8a18a91528a60f20a36957121053e4c219..e296b158aadf18fb40dc6a9b72604c47566c8ae8 100644 --- a/conservancy_beancount/plugin/core.py +++ b/conservancy_beancount/plugin/core.py @@ -259,7 +259,7 @@ class _RequireLinksPostingMetadataHook(_PostingHook): txn: Transaction, post: data.Posting, keys: Sequence[MetaKey], - ) -> Iterable[errormod.InvalidMetadataError]: + ) -> Iterator[errormod.InvalidMetadataError]: have_docs = False for key in keys: try: diff --git a/conservancy_beancount/reports/core.py b/conservancy_beancount/reports/core.py index 82bc36d833b8b596b0ad193c82034294752ff7c5..147c726f483187945b5baeaaa4083b808fd5d41f 100644 --- a/conservancy_beancount/reports/core.py +++ b/conservancy_beancount/reports/core.py @@ -143,7 +143,7 @@ class RelatedPostings(Sequence[data.Posting]): def clear(self) -> None: self._postings.clear() - def iter_with_balance(self) -> Iterable[Tuple[data.Posting, Balance]]: + def iter_with_balance(self) -> Iterator[Tuple[data.Posting, Balance]]: balance = MutableBalance() for post in self: balance.add_amount(post.units)