-
Notifications
You must be signed in to change notification settings - Fork 868
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
Improve INCAR tag check #3621
Improve INCAR tag check #3621
Conversation
I did some research and found typeguard seems to be what we're looking for. from typeguard import check_type, CollectionCheckStrategy
check_type(
value=[1, "hi"], expected_type=list[int],
collection_check_strategy=CollectionCheckStrategy.ALL_ITEMS
)
check_type(
value=[1, "hi"], expected_type=list[int, int],
collection_check_strategy=CollectionCheckStrategy.ALL_ITEMS
)
check_type(
value=[1, "hi"], expected_type=eval("list[int, int]"),
collection_check_strategy=CollectionCheckStrategy.ALL_ITEMS
) However there are still some concerns to address:
|
Can you give me some advice on this @janosh? Do you think it's necessary to have an item-wise type check for INCAR tags (and might need to include an extra dependency |
i think adding |
Yes I was thinking the same, adding a dependency to be used only once would be too much overhead. Actually this should be questions:
|
i don't think so. i don't remember a lot of GitHub issues about this. |
@@ -2570,6 +2571,10 @@ def set_symbols( | |||
self.extend(PotcarSingle.from_symbol_and_functional(el, functional) for el in symbols) | |||
|
|||
|
|||
class UnknownPotcarWarning(UserWarning): | |||
"""Warning raised when POTCAR hashes do not pass validation.""" |
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.
Relocated Warning class after its corresponding class for consistency.
Let's keep the type checking unchanged then, and implement more careful checking when necessary. This PR should be good for review now @janosh . Thanks a lot! |
Guess this PR get forgotten... Can you please review this @janosh ? Thanks. |
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.
thanks @DanielYang59! lgtm
Thanks for reviewing @janosh |
Summary
Some legacy from #3539.
incar_parameters.json
to separate types and values.TODOs
Enable checking of more complex type annotations like
LATTICE_CONSTRAINTS : Sequence[bool, bool, bool])
suggested by @esoteric-ephemera in #3539 (comment).