Changeset - aaa26e9e619c
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-07-20 15:22:23
brettcsmith@brettcsmith.org
data: Make Account.iter_accounts() argument optional.
2 files changed with 8 insertions and 3 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/data.py
Show inline comments
...
 
@@ -222,5 +222,6 @@ class Account(str):
 
    @classmethod
 
    def iter_accounts(cls, s: str) -> Iterator['Account']:
 
    def iter_accounts(cls, s: Optional[str]=None) -> Iterator['Account']:
 
        """Iterate account objects by name or classification
 

	
 
        With no argument, returns an iterator of all known account names.
 
        If you pass in a root account name, or a valid account string, returns
...
 
@@ -230,4 +231,6 @@ class Account(str):
 
        """
 
        if s is None:
 
            return (cls(acct) for acct in cls._meta_map)
 
        # We append a stub subaccount to match root accounts.
 
        if cls.is_account(f'{s}:Test'):
 
        elif cls.is_account(f'{s}:RootsOK'):
 
            return cls.iter_accounts_by_hierarchy(s)
tests/test_data_account.py
Show inline comments
...
 
@@ -446,2 +446,4 @@ def test_iter_accounts_by_classification(asset_hierarchy, arg, expect_subaccts):
 
@pytest.mark.parametrize('arg,expect_subaccts', [
 
    (None, ['Bank:CD', 'Bank:Checking', 'Bank:Savings', 'Cash',
 
            'Investment:Commodities', 'Investment:Stocks']),
 
    ('Assets', ['Bank:CD', 'Bank:Checking', 'Bank:Savings', 'Cash',
...
 
@@ -456,3 +458,3 @@ def test_iter_accounts_by_classification(asset_hierarchy, arg, expect_subaccts):
 
def test_iter_accounts(asset_hierarchy, arg, expect_subaccts):
 
    if arg.startswith('Assets'):
 
    if arg and arg.startswith('Assets'):
 
        prefix = arg
0 comments (0 inline, 0 general)