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

add_imports moves comments following import section #1300

Closed
ziima opened this issue Jul 8, 2020 · 2 comments
Closed

add_imports moves comments following import section #1300

ziima opened this issue Jul 8, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ziima
Copy link

ziima commented Jul 8, 2020

When using add_imports, isort moves comments following the import section to its beginning.

For example a command

isort --check-only --diff test.py --add-import 'from __future__ import unicode_literals'

applied to a file

from __future__ import unicode_literals

from os import path

# A comment for a constant
ANSWER = 42

results in

ERROR: /tmp/test/test.py Imports are incorrectly sorted and/or formatted.
--- /tmp/test/test.py:before	2020-07-08 13:28:31.901108
+++ /tmp/test/test.py:after	2020-07-08 13:32:21.272221
@@ -1,6 +1,6 @@
+# A comment for a constant
 from __future__ import unicode_literals
 
 from os import path
 
-# A comment for a constant
 ANSWER = 42

Affected version: 5.0.5

@timothycrosley timothycrosley added the bug Something isn't working label Jul 9, 2020
@timothycrosley
Copy link
Member

Thanks for reporting! This is fixed with an additional regression test added in 5.0.6.

Thanks!

~Timothy

@ziima
Copy link
Author

ziima commented Jul 9, 2020

Works as well. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants