-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
handle no-member false positive for generators #7505
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
|
||
cm = context_manager() | ||
cm.__enter__() | ||
cm.__exit__(None, None, 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.
There is no corresponding .txt file because no pylint errors or warnings should be in the output.
Pull Request Test Coverage Report for Build 3091981057
π - Coveralls |
8412d63
to
4b205a9
Compare
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.
LGTM, thank you for the fix. (Another possibility would be to make astroid understands decorator better but this is a lot harder to do). I'm going to wait for Daniel's opinion before merging.
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.
This should indeed be fixed in astroid
.
Specifically by changing GeneratorModel
which gets used by bases.Generator
here:
https://github.com/PyCQA/astroid/blob/849d043f3e3cd63881ba919ccba4e6a726947d22/astroid/bases.py#L606
You can find astroid.interpreter.objectmodel.GeneratorModel
here:
https://github.com/PyCQA/astroid/blob/849d043f3e3cd63881ba919ccba4e6a726947d22/astroid/interpreter/objectmodel.py#L601
We would need to add attr___enter__
and attr___exit__
. It should be relatively straightforward to do so. We only need to make sure that we get the typing and arguments that can be passed to these methods correctly.
The signature of these methods can be found here:
https://docs.python.org/3/reference/datamodel.html#object.__enter__
happy to do it. I've followed your instructions and started this draft PR but I'm hoping you can help me fill in the methods as I'm not too sure what they should be.... |
Closing as this should be fixed in |
Type of Changes
Description
A false positive for when a generator called internal enter / exit methods was reported. This PR handles this case in the same way other outlier cases are handled, by adding code to detect this is a generator.
Closes #2567