summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-05-31 12:55:00 +0800
committerClaudiu Popa <pcmanticore@gmail.com>2018-05-31 12:56:28 +0800
commit5fd5aa81483e709cb5c464c7d4bb37c8c39f2afa (patch)
treecfd45af86bbc534168146c0cd5847dc3f63cc275
parentc62742e32213e1da979bb5e7f3d1cec55fbb5d99 (diff)
downloadastroid-git-5fd5aa81483e709cb5c464c7d4bb37c8c39f2afa.tar.gz
Replace some for statements with yield from
-rw-r--r--astroid/arguments.py1
-rw-r--r--astroid/bases.py7
-rw-r--r--astroid/builder.py7
3 files changed, 4 insertions, 11 deletions
diff --git a/astroid/arguments.py b/astroid/arguments.py
index 508f4f85..d0eb40e8 100644
--- a/astroid/arguments.py
+++ b/astroid/arguments.py
@@ -12,7 +12,6 @@ from astroid import nodes
from astroid import util
-
class CallSite(object):
"""Class for understanding arguments passed into a call site
diff --git a/astroid/bases.py b/astroid/bases.py
index 9cf3eecd..b7778056 100644
--- a/astroid/bases.py
+++ b/astroid/bases.py
@@ -169,9 +169,7 @@ class BaseInstance(Proxy):
# XXX frame should be self._proxied, or not ?
get_attr = self.getattr(name, context, lookupclass=False)
- for stmt in _infer_stmts(self._wrap_attr(get_attr, context),
- context, frame=self):
- yield stmt
+ yield from _infer_stmts(self._wrap_attr(get_attr, context), context, frame=self)
except exceptions.AttributeInferenceError as error:
try:
# fallback to class.igetattr since it has some logic to handle
@@ -180,8 +178,7 @@ class BaseInstance(Proxy):
if self._proxied.__class__.__name__ != 'ClassDef':
raise exceptions.InferenceError(**vars(error)) from error
attrs = self._proxied.igetattr(name, context, class_context=False)
- for stmt in self._wrap_attr(attrs, context):
- yield stmt
+ yield from self._wrap_attr(attrs, context)
except exceptions.AttributeInferenceError as error:
raise exceptions.InferenceError(**vars(error)) from error
diff --git a/astroid/builder.py b/astroid/builder.py
index 968aa410..979d3fcc 100644
--- a/astroid/builder.py
+++ b/astroid/builder.py
@@ -17,7 +17,6 @@ import os
import sys
import textwrap
-
from astroid._ast import _parse
from astroid import bases
from astroid import exceptions
@@ -313,8 +312,7 @@ def _extract_expressions(node):
yield real_expr
else:
for child in node.get_children():
- for result in _extract_expressions(child):
- yield result
+ yield from _extract_expressions(child)
def _find_statement_by_line(node, line):
@@ -420,8 +418,7 @@ def extract_node(code, module_name=''):
tree = parse(code, module_name=module_name)
extracted = []
if requested_lines:
- for line in requested_lines:
- extracted.append(_find_statement_by_line(tree, line))
+ extracted = [_find_statement_by_line(tree, line) for line in requested_lines]
# Modifies the tree.
extracted.extend(_extract_expressions(tree))