ericsnowcurrently avatar ericsnowcurrently committed 5f905d5 Draft

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

Comments (0)

Files changed (4)

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()
 

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)

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]:

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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.