-
Notifications
You must be signed in to change notification settings - Fork 23
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
Suggestion on code actions for unsafe rules #55
Comments
I was also fiddling with the idea of adding def f():
a = t # F821: Undefined name `t`
a = 2 # F841: Local variable `a` is assigned but never used Running def f():
pass My point is that I would expect the However I am happy to hear the opinion of others on this. |
I think this would be more reasonable; it at least gives the programmer a visual reminder that the action is not-safe
My idea was that Instead, for cases without This way they are visual in the editor, but you have to apply them manually on a rule-by-rule basis (which is why I thought having a visual reminder that the code action is Simply put: always run with |
- Update unsafe code actions to contain `(unsafe)` at the end of the message - Prevent the `Fix All` code action from applying unsafe codeactions - Update the README to mention this behaviour
- Update unsafe code actions to contain `(unsafe)` at the end of the message - Prevent the `Fix All` code action from applying unsafe codeactions - Update the README to mention this behaviour
I have to reopen this, since in the LSP specification it explicitly says
So unsafe fixes should never be fixed using the Fix all action. |
Ah my bad, we already fixed this. |
With the introduction of the
unsafe
auto-fixes in ruff, I feel having a single toggle in pylsp for enabling/disabling them are quite too inefficient or "too safe", as either make all unsafe fixes disappear, or making theFix all
-code action quite unsafe in natureMy idea is instead, if you leave
pylsp.plugins.ruff.unsafeFixes
asFalse
then theFix all
-code-action should fix allsafe
rules, but still make the individualunsafe
rules available and actionable on the respective diagnostic/locationThis strikes the balance of being safe with the
Fix all
-code-action, and still being able to discover and make a choice on theunsafe
fix(If you instead set
pylsp.plugins.ruff.unsafeFixes
toTrue
, then the plugin should work exactly as now (because then you signed up for the "unsafety-ness"))With that being said, the
unsafe
-code actions should probably indicate they are unsafe somehowIf this isn't too crazy of an idea, I'd happily try to implement it :-)
The text was updated successfully, but these errors were encountered: