-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Infer return value of None for correctly inferred functions with no returns #983
Infer return value of None for correctly inferred functions with no returns #983
Conversation
616128c
to
ff719c8
Compare
Rebased to fix conflict with changes to |
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.
All in all this looks like a reasonable change. Thanks for also opening pylint-dev/pylint#4428 to fix the pylint tests!
I ran some tests and didn't notice anything unusual, so should be ok to merge once all discussions are resolved.
7ec6a68
to
d66e3d1
Compare
d66e3d1
to
6ba7778
Compare
Thanks @cdce8p ! |
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.
@nelfin thanks for your answers! It is all good for me. Just left a comment regarding adding a comment but feel free to add it or not.
Ref pylint-dev#485. If the function was inferred (unlike many compiler-builtins) and it contains no Return nodes, then the implicit return value is None.
Ref pylint-dev#663. This test did not actually check for regression of the issue fixed in 55076ca (i.e. it also passed on c87bea1 before the fix was applied). Additionally, it over-specified the behaviour it was attempting to check: whether the value returned from the context manager was Uninferable was not directly relevant to the test, so when this value changed due to unrelated fixes in inference, this test failed.
Ref pylint-dev#485. To avoid additional breakage, we optionally extend is_abstract to consider functions whose body is any raise statement (not just raise NotImplementedError)
6ba7778
to
ce10268
Compare
I updated the comment with a more in-depth explanation |
Thanks @nelfin ! |
* Add regression tests of inference of implicit None return Ref pylint-dev/astroid#485. Depends on pylint-dev/astroid#983. * Update tests to return size from __len__ No reason why they can't when it's relevant, instead of disabling this warning
Steps
Description
Functions with empty bodies or no return statements e.g.
def f(): pass
were returned asUninferable
frominfer_call_result
Type of Changes
Related Issue
Closes #485
Ref #663
Pylint PR: pylint-dev/pylint#4428