From dfc4f30d19cf5d9b9d5863c232d12e9f4300dcd7 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Mon, 3 Sep 2018 16:15:50 -0400 Subject: [PATCH] Fix PR #357 Turns out that comments are associated with a specific AST node in python, and are not AST nodes on their own. Therefore, "continue" after detecting the shebang comment in fact causes the future import to be placed after the first AST node, which might be anything. --- src/libfuturize/fixer_util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libfuturize/fixer_util.py b/src/libfuturize/fixer_util.py index a10184c7..345bb3a6 100644 --- a/src/libfuturize/fixer_util.py +++ b/src/libfuturize/fixer_util.py @@ -243,7 +243,6 @@ def future_import(feature, node): # Is it a shebang or encoding line? if is_shebang_comment(node) or is_encoding_comment(node): shebang_encoding_idx = idx - continue if is_docstring(node): # skip over docstring continue