Skip to content

__future__ imports adding in wrong sorting order #445

Closed
@ascandella

Description

@ascandella

These appear to be backwards from the recommended (isort/alphabetical) order:

$ cat test.py
import logging

def main():
    pass
$ futurize --all-imports test.py                                                                                                                                                                   RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored test.py
--- test.py	(original)
+++ test.py	(refactored)
@@ -1,3 +1,10 @@
+from __future__ import unicode_literals
+from __future__ import print_function
+from __future__ import division
+from __future__ import absolute_import
+from future import standard_library
+standard_library.install_aliases()
+from builtins import *
 import logging

 def main():
RefactoringTool: Files that need to be modified:
RefactoringTool: test.py

$ futurize  -f libfuturize.fixes.fix_add__future__imports_except_unicode_literals test.py                                                                                                          
RefactoringTool: Refactored test.py
--- test.py	(original)
+++ test.py	(refactored)
@@ -1,3 +1,6 @@
+from __future__ import print_function
+from __future__ import division
+from __future__ import absolute_import
 import logging

 def main():
RefactoringTool: Files that need to be modified:
RefactoringTool: test.py

Changing the ordering in the fixers appears to fix the issue, but I'm wondering if this is somehow intentional or there's another reason for this, given the docstring comments on the fixers showing the imports in the correct order.

If this is a bug, and it is agreed they should be in alphabetical order, I can put up a PR to fix it.

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