diff --git a/ChangeLog b/ChangeLog index 52007414b8..4427e1c393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -63,6 +63,7 @@ Release date: TBA attribute to itself without any prior assignment. Closes #1555 + Closes #6221 * The concept of checker priority has been removed. diff --git a/doc/whatsnew/2.14.rst b/doc/whatsnew/2.14.rst index dfe548f4bd..01d635aa84 100644 --- a/doc/whatsnew/2.14.rst +++ b/doc/whatsnew/2.14.rst @@ -81,3 +81,4 @@ Other Changes attribute to itself without any prior assignment. Closes #1555 + Closes #6221 diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 2ab5ced330..0d2c8f691a 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -1053,6 +1053,11 @@ def visit_attribute(self, node: nodes.Attribute) -> None: missingattr.add((owner, name)) continue else: + if isinstance(attr_nodes, nodes.NodeNG): + # If owner was a living object, attr_nodes might be a node itself + # Faster than retrieving the module object and testing _is_c_extension() + # https://github.com/PyCQA/pylint/pull/6235#issuecomment-1093098869 + break # pragma: no cover for attr_node in attr_nodes: attr_parent = attr_node.parent # Skip augmented assignments