Skip to content

Commit

Permalink
Fix a crash in the optional private_import extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls authored and Pierre-Sassoulas committed Jun 6, 2022
1 parent 3ac7d11 commit 6fac84e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/whatsnew/2/2.14/full.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Release date: TBA

Closes #6810

* Fix a crash in the optional ``pylint.extensions.private_import`` extension.

Closes #6624


What's New in Pylint 2.14.0?
----------------------------
Expand Down
3 changes: 2 additions & 1 deletion pylint/extensions/private_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def _assignments_call_private_name(
while isinstance(current_attribute, (nodes.Attribute, nodes.Call)):
if isinstance(current_attribute, nodes.Call):
current_attribute = current_attribute.func
current_attribute = current_attribute.expr
if not isinstance(current_attribute, nodes.Name):
current_attribute = current_attribute.expr
if (
isinstance(current_attribute, nodes.Name)
and current_attribute.name == private_name
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/ext/private_import/private_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,16 @@ def c2_func() -> _TypeContainerC.C:
import _private_module_unreachable # [import-private-name]
my_var8: _private_module_unreachable.Thing8
_private_module_unreachable.Thing8()


# pylint: disable=too-few-public-methods
class Regression6624:
"""Ensure that an import statement precedes this case."""
def get_example(self):
example: Example = Example().save()
return example


class Example:
def save(self):
return self

0 comments on commit 6fac84e

Please # to comment.