Long imports and noqa
Hola, I have an import from the following format:
from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd # noqa: E402
from aaaaaaa import eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffff # noqa: E402
When running isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df it prints:
-from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd # noqa: E402
-from aaaaaaa import eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffff # noqa: E402
+from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, \
+ fffffffffffffffffffff # noqa: E402
Running isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df again, it prints:
-from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, \
- fffffffffffffffffffff # noqa: E402
+from aaaaaaa import fffffffffffffffffffff # noqa: E402
+from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Besides of the strange behavior that yields two different formattings, the second one missing the noqa.
I'm not able to reproduce locally using isort 5.13.2.
I recommend closing this issue. Thanks!
@DanielNoord This issue is not reproducible. I recommend closing this issue.
Can I help reproducing it? It happens to me on two different ubuntu computers I also tested it inside a docker to make sure it can be reproduced
I see in your diff output that the file you're testing is larger than just the two lines that you originally posted.
Please confirm that you can reproduce using these steps:
cd $HOME
mkdir whatever-bogus
cd whatever-bogus
git init
# Copy a.py to the whatever-bogus directory
isort --version
isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df
isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df
If so, please provide the full a.py file here. Thanks!
(whatever-bogus isn't an important name, I'm just suggesting to use a temp directory and prevent isort from searching any higher in the filesystem by making it a git repository.)
@DanielNoord I'm able to reproduce this now. The issue is valid and needs to be reopened -- isort has non-idempotent behavior.
@matan1008 You were changing the file between --check-only runs, as shown by the changing timestamp of the file in the diff output, but you didn't document this. When reporting issues to projects in the future, please document all of the steps you're taking. Thanks! 👍
For others' benefit, the full file is:
from aaaaaaa import bbbbbbbbbbbbbbbbb, ccccccccccccccccccc, dddddddddddddddd # noqa: E402
from aaaaaaa import eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffff # noqa: E402
print(fffffffffffffffffffff)
print(dddddddddddddddd)
and the full steps to reproduce are:
mkdir whatever-bogus
cd whatever-bogus
git init
# Copy a.py to this directory
# Show the diff, then run isort
isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df
isort . -m HANGING_INDENT -l 120 --combine-as
# Demonstrate non-idempotent behavior
isort . -m HANGING_INDENT -l 120 --check-only --combine-as --df
Could you reopen the issue (and perhaps fix it)?