-
Notifications
You must be signed in to change notification settings - Fork 2
Pass AbstractSets to Transaction #10
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
Conversation
beancount-stubs/core/data.pyi
Outdated
@@ -129,8 +130,8 @@ class Transaction: | |||
flag: Flag | |||
payee: Optional[str] | |||
narration: str | |||
tags: Optional[set] | |||
links: Optional[set] | |||
tags: FrozenSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, joke's on me—when I said "matches upstream code" I was looking at master
.
How about:
tags: FrozenSet | |
tags: FrozenSet | set |
Or, although that allow_none_for_tags_and_links
switch defaults to False
:
tags: FrozenSet | |
tags: FrozenSet | set | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's go with None
being a part of the set. And no worries about the branch mismatch, been in the same position a week ago, writing my own importer... :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, since I'm annotating args, the docs say I should use AbstractSet
.
>>> from typing import AbstractSet
>>> issubclass(set, AbstractSet)
True
>>> issubclass(frozenset, AbstractSet)
True
Although AbstractSet
is deprecated since 3.9, most of typing
is too, so I won't worry about that yet.
Should I fix Document
accordingly in this or another PR?
5b4828c
to
5872994
Compare
This way, `frozenset`s (like `EMPTY_SET`) are considered valid. They're `Optional` because Beancount can occasionally be convinced to allow `None`s into these fields: https://github.com/beancount/beancount/blob/2.3.6/beancount/core/data.py#L500-L502
This way, `frozenset`s (like `EMPTY_SET`) are considered valid. They're `Optional` because Beancount can occasionally be convinced to allow `None`s into these fields: https://github.com/beancount/beancount/blob/2.3.6/beancount/core/data.py#L500-L502
Matches upstream code. Fixes #4.