-
Notifications
You must be signed in to change notification settings - Fork 867
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
Fix mypy
errors on master branch
#3977
Conversation
if self.solid_compat: | ||
entries = self.solid_compat.process_entries(entries, clean=True, inplace=inplace, n_workers=n_workers) | ||
return [entries] | ||
return [entries] # DEBUG: incompatible return type |
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.
Incompatible return type, self.solid_compat.process_entries
returns list[AnyComputedEntry]
and this method should return list[AnyComputedEntry]
instead of list[list[AnyComputedEntry]]
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.
maybe wrapping entries
as [entries]
was added before the above check?
if isinstance(entries, ComputedEntry):
entries = [entries]
do any tests break when you just return entries
?
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.
just noticed that it says "preprocess entries" in the comment above so probably wasn't meant to return at all on this line. tests pass without it. can you confirm @rkingsbury?
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.
Indeed, there should not have been a return
statement on that line. I'm not sure when that was introduced (can't tell from the git blame) but that was actually a pretty serious bug. It was effectively preventing the aqueous compatibility scheme from doing anything when given default arguments.
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.
@rkingsbury can you think of a good test to add that would have caught this breaking change?
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.
Indeed, there should not have been a
return
statement on that line. I'm not sure when that was introduced (can't tell from the git blame) but that was actually a pretty serious bug. It was effectively preventing the aqueous compatibility scheme from doing anything when given default arguments.
I have no recollection of why I would have added this return statement, sadly I think it's likely that I added it to do some sort of manual checking that it worked correctly when run with joblib and then failed to remove it. Sorry.
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.
for once, mypy
proves its worth 😄
in general, can't wait for materials science codes to be fully statically typed!
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.
@rkingsbury can you think of a good test to add that would have caught this breaking change?
What I would have expected to happen is with default arguments, the ComputedEntry
would be returned with the normal solid energy corrections (MaterialsProject2020Compatibility
) but no aqueous corrections. I guess existing tests didn't catch it because many (even most) solids won't receive any Aqueous corrections when they are processed. It's only a few materials like diatomic gases and materials containing OH that would get the adjustment.
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! 👍
Thanks for reviewing. There was one type error for |
Summary
mypy
errors on master branch, to fix Some type annotations errors when trying to merge master into my local development branch. #3976