-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
import lost after formatting #1542
import lost after formatting #1542
Comments
@arthurxlee, can you provide the output of
Which, I believe is correct. This leads me to believe it is happening only with certain settings, or that the actual code is different from the given example in some way. In case it's helpful, this UI: https://pycqa.github.io/isort/docs/quick_start/0.-try/ can help to produce a minimal example. Thanks! ~Timothy |
Attached is the output from show config. |
I would also suggest that the lines should not be folded since the inline comment would very probably not apply to the other lines, so them folding may not be desirable. |
Thank you for sharing your configuration, and I'm sorry you've been impacted by this issue! With the configuration, I was able to quickly confirm the issue was isolated to the wrap mode being used (which is a relatively newer community contributed mode). I've fixed this issue and added additional regression tests to ensure it doesn't happen going forward.
I agree with this in principle, though it is really very hard to tell comment intention.
In theory there is some optimizations that could be made for just this wrap-mode, but if you really want to make sure comment intention is explicitly mapped, the only way to do that would be to use a mode that leads to one import per a line. Otherwise, for individual cases like this you can tell isort to skip the line with the comment:
Thanks! ~Timothy |
I have a file that looks like this
The content from line 2 could be folded to line1, but I suspect the comment at the end of line 2 gets in the way and the entire line will be lost after formatting.
Using isort version 5.5.4
The text was updated successfully, but these errors were encountered: