-
Notifications
You must be signed in to change notification settings - Fork 771
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
Aggressive import "fixing" creates syntactically invalid code #3181
Comments
for 3 I'm assuming you have
|
Yes which used to be safe. But the definition of 'all' seems to have changed. So I'm turning that off. |
We recently added 2 new fix all code actions in the extension and unfortunately,
will automatically pick up any fix all existing. while we taking a look at how to improve our behavior, you can use this to turn it off "source.fixAll.unusedImports": false for other fix all, you can take a look at this |
There is also this issue - microsoft/vscode#82718 - in vscode that is tracking editor.codeActionsOnSave intellisense issue. Basically, editor.codeActionsOnSave currently only shows 2 predefined entries; source.fixAll and source.organizeImports. problem is source.fixAll is a catch all option. but it doesn't show all individual fixAlls exposed by all extensions. so a lot of people end up just put "source.fixAll" and hope when extensions are updated, new fix all code action added won't cause a problem. the issue above will let each extensions expose fixAlls they provide so users can enable only ones they want rather than enable all blindly and hope for best. For now, people need to reference documentations of all extensions they use to find out specific names of each fix all code actions and use them to configure or use catch all - "source.fixAll" |
IMHO the real problem here is the syntax |
the feature of removing unused imports is going to remove unused imports. Instead of the On/Off coarse behaviour of source.fixAll.unusedImports maybe we could add a way to tag certain imports as expected to be unused. |
The tag is already there, if it's possible to have pylance recognise the import (and subsequent calls to it) is in a try clause, ie have a look around for the context. |
"remove all unused imports" will only remove top level imports now. we still allow users invoking "remove unused imports" for nested imports but now we will remove leading whitespaces correctly. thank you for reporting the issue. |
This issue has been fixed in prerelease version 2022.9.11, which we've just released. You can find the changelog here: CHANGELOG.md |
Environment data
Code Snippet
Repro Steps
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: