-
Notifications
You must be signed in to change notification settings - Fork 767
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
"Remove unused imports" removes all imports #1547
Comments
This sounds like it might be a pylance bug? |
Yeah repros in VS code. |
@ttSpace please try writing imports in seperate lines, like this: import array
import glob
import math
math.cos(0) and try using remove unused imports and see whether all imports are removed. |
As you can see, it doesn't remove all imports. Is that okay? |
The code action doesn't remove all imports, only the one the quick fix is attached to (per diagnostic), so that's working as expected. It deleting the full line sounds like a bug, but I don't know if that's because our change is wrong, or if the editor is applying all of the fixes with the same name on the same line at once. |
Actually we seldom write many imports in a single line, so there's no need to worry about that. |
it should be fixed in 2021.8.2 released today (2021.8.19) |
Those versions don't align with any version we have for Pylance. Can you check the logs for the Pylance version you're using? |
I see below info in Pylance output window.
|
VS is still on a 4 month old build of Pylance (note the version difference). When it's updated, it will get the fix. |
I use it in today's build, is that supposed to happen like the following? I have to click a few times to remove unused import.
|
Quick fixes are offered per-diagnostic. In VS Code, you can hover over each diagnostic and get a lightbulb per, and that's how the LSP works. I'm not sure how VS does this, but it looks like it offers a lightbulb per line. We're doing what we expect (one quick fix per diagnostic), but it seems like this UI only offers up one of them per line, or something. #1722 covers a quick fix that would remove all, but overall I think that this would be something to report on PTVS for investigation, as Pylance isn't behaving incorrectly according to the protocol. |
Describe the bug
Steps to Reproduce
Actual behavior
It removes all imports.
![image](https://user-images.githubusercontent.com/82852072/124252894-0b6a7d80-db5a-11eb-9a78-fbb2920114f0.png)
The text was updated successfully, but these errors were encountered: