isort
isort copied to clipboard
Comments in group imports are moved to a single line causing line too long violation (black, flake8)
Hi, this issue seems to be related to #1009 #1843.
When using isort
as a pre-commit hook with black
profile. My commented imports are being moved to a single line.
Commented imports are intentional because I have some work in progress but I'd still like to commit (without --no-verify
)
Example: Before:
from dj_rest_auth.views import (
LoginView,
LogoutView,
# PasswordChangeView,
# PasswordResetConfirmView,
# PasswordResetView,
# UserDetailsView,
)
After:
from dj_rest_auth.views import ( # PasswordChangeView,; PasswordResetConfirmView,; PasswordResetView,; UserDetailsView,
LoginView,
LogoutView,
)
My pre-commit hook configuration:
# isort
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: &isort_args
- --line-length=100
- --profile=black
- --combine-as
- --lines-after-imports=2
- --src-path=app
- id: isort
name: isort (cython)
types: [ cython ]
args: *isort_args
- id: isort
name: isort (pyi)
types: [ pyi ]
args: *isort_args
I wonder if it's related to #1839 as well.
Here is another problem, what if I want to disable isort and black.
from dj_rest_auth.views import ( #isort: skip
LoginView,
LogoutView, # hey, I like it this way :p
) # fmt: skip
The fmt: skip
is moved up and that breaks black.
I'm also wondering if it's possible to leave comments on the line on which they are written. If I want to comment my imports (like I do above) and I'm using black
profile, then it makes sense to allow it. But I assume this is very difficult to implement?
This is driving me nuts 🤣 . Has anyone found a solution?