diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-12-29 10:20:00 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-12-29 10:27:39 +0100 |
commit | 5a9ea7ce8884c3040a21b91b45ab0a7951439f0f (patch) | |
tree | 86349411f845c508605ba231352a73241952c32d /pylint/checkers/variables.py | |
parent | 17325f2f7c8cf43f7ae61ba6726b5117cc11066c (diff) | |
download | pylint-git-fix-crash-in-attribute-check.tar.gz |
Fix a crash in `undefined-variable` caused by chained attributes in metaclassfix-crash-in-attribute-check
Close #3742
Diffstat (limited to 'pylint/checkers/variables.py')
-rw-r--r-- | pylint/checkers/variables.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index b6a2978a5..986f76fd2 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -2037,7 +2037,10 @@ class VariablesChecker(BaseChecker): if isinstance(klass._metaclass, astroid.Name): name = klass._metaclass.name elif isinstance(klass._metaclass, astroid.Attribute) and klass._metaclass.expr: - name = klass._metaclass.expr.name + attr = klass._metaclass.expr + while not isinstance(attr, astroid.Name): + attr = attr.expr + name = attr.name elif metaclass: name = metaclass.root().name |