summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-11-20 13:10:36 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-11-20 13:10:36 +0200
commit6744f44b7d50024283972badb396d3d357a71c74 (patch)
treeb8dd6d903b64e12431f21fc12ca54af0329dee45
parentfb6b47b10084423e6c43a30538cb8eca39ce7408 (diff)
downloadpylint-6744f44b7d50024283972badb396d3d357a71c74.tar.gz
Simplify the unflatten algorithm in order to not use NodeNG anymore.
-rw-r--r--pylint/checkers/typecheck.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 0f5d7af..da9daf7 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -28,6 +28,7 @@ import astroid.arguments
from astroid import exceptions
from astroid import objects
from astroid import node_classes
+from astroid import bases
import six
from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE
@@ -51,12 +52,13 @@ STR_FORMAT = "%s.str.format" % BUILTINS
def _unflatten(iterable):
- for elem in iterable:
+ for index, elem in enumerate(iterable):
if (isinstance(elem, collections.Sequence) and
not isinstance(elem, six.string_types)):
- for subelem in _unflatten(elem):
- yield subelem
- elif isinstance(elem, node_classes.NodeNG):
+ for elem in _unflatten(elem):
+ yield elem
+ elif elem and not index:
+ # We're interested only in the first element.
yield elem
@@ -735,7 +737,7 @@ accessed. Python regular expressions are accepted.'}
if infered is None or infered is astroid.YES:
continue
- if isinstance(infered, astroid.bases.Generator):
+ if isinstance(infered, bases.Generator):
# Check if we are dealing with a function decorated
# with contextlib.contextmanager.
if decorated_with(infered.parent, ['contextlib.contextmanager']):