summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Drozd <nicholasdrozd@gmail.com>2019-12-23 12:28:52 -0600
committerClaudiu Popa <pcmanticore@gmail.com>2019-12-24 10:08:53 +0100
commitbc4dd3db4065007fc3e1ca3fb64349a61f584005 (patch)
tree4267f4d5cbda3a38ceea393b603567af5580e62f
parent3d74305efdbc6aa58784a0222e4a1eef6a33e2fa (diff)
downloadastroid-git-bc4dd3db4065007fc3e1ca3fb64349a61f584005.tar.gz
Enable else-if-used extension
-rw-r--r--astroid/inference.py12
-rw-r--r--astroid/scoped_nodes.py19
-rw-r--r--pylintrc1
3 files changed, 16 insertions, 16 deletions
diff --git a/astroid/inference.py b/astroid/inference.py
index bfd94b92..a563287d 100644
--- a/astroid/inference.py
+++ b/astroid/inference.py
@@ -372,13 +372,13 @@ def infer_subscript(self, context=None):
index_value = _SUBSCRIPT_SENTINEL
if value.__class__ == bases.Instance:
index_value = index
+ elif index.__class__ == bases.Instance:
+ instance_as_index = helpers.class_instance_as_index(index)
+ if instance_as_index:
+ index_value = instance_as_index
else:
- if index.__class__ == bases.Instance:
- instance_as_index = helpers.class_instance_as_index(index)
- if instance_as_index:
- index_value = instance_as_index
- else:
- index_value = index
+ index_value = index
+
if index_value is _SUBSCRIPT_SENTINEL:
raise exceptions.InferenceError(node=self, context=context)
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 440984e4..ad727b13 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -2486,17 +2486,16 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, node_classes.Statement
yield from function.infer_call_result(
caller=self, context=context
)
+ # If we have a metaclass, we're accessing this attribute through
+ # the class itself, which means we can solve the property
+ elif metaclass:
+ # Resolve a property as long as it is not accessed through
+ # the class itself.
+ yield from function.infer_call_result(
+ caller=self, context=context
+ )
else:
- # If we have a metaclass, we're accessing this attribute through
- # the class itself, which means we can solve the property
- if metaclass:
- # Resolve a property as long as it is not accessed through
- # the class itself.
- yield from function.infer_call_result(
- caller=self, context=context
- )
- else:
- yield inferred
+ yield inferred
else:
yield function_to_method(inferred, self)
except exceptions.AttributeInferenceError as error:
diff --git a/pylintrc b/pylintrc
index b752ee50..f86cbbe7 100644
--- a/pylintrc
+++ b/pylintrc
@@ -23,6 +23,7 @@ persistent=yes
# usually to register additional checkers.
load-plugins=
+ pylint.extensions.check_elif,
# Use multiple processes to speed up Pylint.
jobs=1