Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account.has_component() does not return boolean #376

Open
blais opened this issue Feb 27, 2019 · 0 comments
Open

account.has_component() does not return boolean #376

blais opened this issue Feb 27, 2019 · 0 comments
Labels
BUG This is a bug, not a feature request; something isn't working. core-ops Component: Core data structures and stream ops P2 Low priority, addressing would result in useful improvements

Comments

@blais
Copy link
Member

blais commented Feb 27, 2019

Original report by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


account.has_component() claims to return a boolean:

def has_component(account_name, component):
    """Return true if one of the account contains a given component.

but it doesn't:

from beancount.core import account

a = "Assets:Test:Bar"

print(account.has_component(a, 'Barx'))
print(account.has_component(a, 'Bar'))

results in:

None
<re.Match object; span=(11, 15), match=':Bar'>

I'm not sure if this actually matters in practice but I think the docs should match reality (or vice versa ;)

This can be fixed by adding bool() around the return.

The same problem applies to account.parent_matcher(). Unfortunately I don't know the best way to solve it there.

@blais blais added P2 Low priority, addressing would result in useful improvements core-ops Component: Core data structures and stream ops BUG This is a bug, not a feature request; something isn't working. labels May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG This is a bug, not a feature request; something isn't working. core-ops Component: Core data structures and stream ops P2 Low priority, addressing would result in useful improvements
Projects
None yet
Development

No branches or pull requests

1 participant