Skip to content

Suggestion on code actions for unsafe rules #55

@magnuslarsen

Description

@magnuslarsen

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 the Fix all-code action quite unsafe in nature

My idea is instead, if you leave pylsp.plugins.ruff.unsafeFixes as False then the Fix all-code-action should fix all safe rules, but still make the individual unsafe rules available and actionable on the respective diagnostic/location

This strikes the balance of being safe with the Fix all-code-action, and still being able to discover and make a choice on the unsafe fix

(If you instead set pylsp.plugins.ruff.unsafeFixes to True, 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 somehow

If this isn't too crazy of an idea, I'd happily try to implement it :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions