Commits

Benjamin Peterson committed 85e7941

simplify condition

Comments (0)

Files changed (1)

lib2to3/refactor.py

                 if have_docstring:
                     break
                 have_docstring = True
-            elif tp == token.NAME:
-                if value == u"from":
+            elif tp == token.NAME and value == u"from":
+                tp, value = advance()
+                if tp != token.NAME and value != u"__future__":
+                    break
+                tp, value = advance()
+                if tp != token.NAME and value != u"import":
+                    break
+                tp, value = advance()
+                if tp == token.OP and value == u"(":
                     tp, value = advance()
-                    if tp != token.NAME and value != u"__future__":
+                while tp == token.NAME:
+                    if value == u"print_function":
+                        return True
+                    tp, value = advance()
+                    if tp != token.OP and value != u",":
                         break
                     tp, value = advance()
-                    if tp != token.NAME and value != u"import":
-                        break
-                    tp, value = advance()
-                    if tp == token.OP and value == u"(":
-                        tp, value = advance()
-                    while tp == token.NAME:
-                        if value == u"print_function":
-                            return True
-                        tp, value = advance()
-                        if tp != token.OP and value != u",":
-                            break
-                        tp, value = advance()
-                else:
-                    break
             else:
                 break
     except StopIteration: