-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update regression tests for PyCQA/astroid#940 #4466
Update regression tests for PyCQA/astroid#940 #4466
Conversation
Ref pylint-dev/astroid#940. These tests failed after fixing inference of Enum.__members__ due to unexpected "not-iterable" warnings raised. These warnings were not false-positives, as the test definition would have raised TypeError at runtime: .keys and .values on dict/mappingproxy are not properties, but methods.
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.
The following guard can actually be removed if Enum.__members__
is correctly inferred:
if (
owner.parent
and isinstance(owner.parent, astroid.ClassDef)
and owner.parent.name == "EnumMeta"
and owner_name == "__members__"
and node.attrname in ["items", "values", "keys"]
):
# Avoid false positive on Enum.__members__.{items(), values, keys}
# See https://github.com/PyCQA/pylint/issues/4123
return False
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.
Thank you. Is there a reason why you did not remove the guard you detected ?
To decouple this MR from the astroid changes. If I remove that guard, then this changeset should only be merged after pylint-dev/astroid#941, but if I leave it in then this can be merged before (since all the tests still pass) and that guard removed in a later change. |
Thank you for the explanation :) |
Steps
doc/whatsnew/<current release.rst>
.Description
Changes to the inference of properties in a class context affected some existing tests
Type of Changes
Related Issue
Ref pylint-dev/astroid#940
Depends on pylint-dev/astroid#941