Skip to content

futurize displaces sometimes "#!/usr/bin/env python" from first line #43

Closed
@wluebbe

Description

@wluebbe

As can be seen from the test below the from __future__ ... statement goes to the first line if the shebang line is followed by a blank or a comment line.
If it is followed by a doc-string it is OK.

While futurizing Sage a few py-scripts were executed by bash and the import statements tried some screen-shots ... Quite surprising.

--- ./shebang-blank.py  (original)
+++ ./shebang-blank.py  (refactored)
@@ -1,3 +1,4 @@
+from __future__ import division
 #!/usr/bin/env python

 import math
--- ./shebang-comment.py    (original)
+++ ./shebang-comment.py    (refactored)
@@ -1,3 +1,4 @@
+from __future__ import division
 #!/usr/bin/env python
 # some comments
 # and more comments
--- ./shebang-docstring.py  (original)
+++ ./shebang-docstring.py  (refactored)
@@ -2,6 +2,7 @@
 """
 a doc string
 """
+from __future__ import division

 import math

Would you like to have my 3 small test scripts?
Are attachments possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions