Commits

Eric Snow  committed 5f905d5 Draft

don't need to explicitly iterate for "yield from"

  • Participants
  • Parent commits b0ea77f

Comments (0)

Files changed (4)

File pylt/parsing/python.py

         self._tokens = list(tokens)
 
     def get_tokens(self):
-        yield from iter(self._tokens)
+        yield from self._tokens
 
 
 class SimpleStatement(ParseUnit):
         self.body = list(body)
 
     def get_tokens(self):
-        yield from iter(self.header)
+        yield from self.header
         for statement in self.body:
             yield from statement.get_tokens()
 

File pylt/transforms/syntax/given_postfix.py

     # turn the given clause into a function definition
     yield from make_func_header(free)
 
-    yield from iter(block)
+    yield from block
     yield (token.NEWLINE, '\n')
     yield (token.NAME, 'return')
     yield (token.NAME, 'locals')
 def transform_tokens_new(tokens):
     # http://www.python.org/dev/peps/pep-3150/#id33
     parser = Parser()
-    for statement in parser.ParseSource(tokens):
+    for statement in parser.parse_source(tokens):
         if isinstance(statement, CompoundStatement):
             if statement.has_token(token.NAME, 'given'):
                 yield from handle_given(statement)

File pylt/transforms/syntax/given_postfix_alt.py

     # turn the given clause into a function definition
     yield from make_func_header(free)
 
-    yield from iter(block)
+    yield from block
     yield (token.NEWLINE, '\n')
     yield (token.NAME, 'return')
     yield (token.NAME, 'locals')
 
 
 def transform_simple_statements(first, tokens):
-    yield from iter(first)
+    yield from first
     for tok in tokens:
         # XXX is a given statement incompatible with ";"?
         if tok.type == token.COLON:
     if declaration[-2].string == 'given':
         yield from handle_given(declaration, block)
     else:
-        yield from iter(declaration)
+        yield from declaration
         yield from block
 
 
         if tok.type == token.SEMI:
             return transform_simple_statements(statement, tokens)
         elif tok.type in [token.NEWLINE, token.ENDMARKER]:
-            return iter(statement)
+            return statement
         elif tok.type == token.COLON:
             return transform_complex_statement(statement, tokens)
         elif tok.type in [token.INDENT, token.DEDENT]:

File pylt/transforms/syntax/given_prefix.py

     # turn the given clause into a function definition
     yield from make_func_header(free)
 
-    yield from iter(block)
+    yield from block
     yield (token.NEWLINE, '\n')
     yield (token.NAME, 'return')
     yield (token.NAME, 'locals')