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

isort: off not working #1398

Closed
chdsbd opened this issue Aug 21, 2020 · 3 comments
Closed

isort: off not working #1398

chdsbd opened this issue Aug 21, 2020 · 3 comments

Comments

@chdsbd
Copy link

chdsbd commented Aug 21, 2020

I was having trouble getting the isort: off comment to work. I was able to get it to work in another file, but not in this example.

# isort: off
from app.resources import (
    db,
    cache
)
# isort: on

.isort.cfg

[settings]
profile=black

./.venv/bin/isort main.py --diff output

--- /Users/chris/projects/isort-reproduction/main.py:before	2020-08-21 12:12:04.127048
+++ /Users/chris/projects/isort-reproduction/main.py:after	2020-08-21 12:14:49.983382
@@ -1,6 +1,4 @@
 # isort: off
-from app.resources import (
-    db,
-    cache
-)
+from app.resources import cache, db
+
 # isort: on

example repository: https://github.com/chdsbd/isort-reproduction


EDIT: strangely if I add two # to the top of the file this issue disappears:

#
#

# isort: off
from app.resources import (
    db,
    cache
)
# isort: on
@timothycrosley
Copy link
Member

Hi @chdsbd,

Thanks for reporting! Thanks to your bug report, this has been fixed in develop and will make it's way out in the next release of isort.

Background info: isort is very cautious with the top comment of a file, since it can contain execution information, encoding info, etc... This is a case where it still makes sense to to act off that comment, but just in case you were curious as to the why behind why it would work, except for this very specific case.

Thanks!

~Timothy

@chdsbd
Copy link
Author

chdsbd commented Aug 22, 2020

Thanks for the quick fix!

@timothycrosley
Copy link
Member

This change has just been deployed to PyPI in version 5.5.0

Thanks!

~Timothy

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

No branches or pull requests

2 participants