Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__future__ imports adding in wrong sorting order #445

Closed
ascandella opened this issue Apr 3, 2019 · 0 comments · Fixed by #446
Closed

__future__ imports adding in wrong sorting order #445

ascandella opened this issue Apr 3, 2019 · 0 comments · Fixed by #446

Comments

@ascandella
Copy link
Contributor

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.

ascandella added a commit to ascandella/python-future that referenced this issue Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant