Skip to content
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

Ignore fixable setting for context actions #249

Open
urob opened this issue Aug 28, 2023 · 3 comments
Open

Ignore fixable setting for context actions #249

urob opened this issue Aug 28, 2023 · 3 comments
Labels
enhancement New feature or request polar

Comments

@urob
Copy link

urob commented Aug 28, 2023

First, thanks for making this plugin! This is great.

I realize that this may require coordination with the upstream ruff project but since this primarily affects the IDE integration, I am opening it here.

Context

I am using ruff's fixable and unfixable setting to disable autofixing certain rules on save / when re-formatting.

The problem is that this also eliminates the auto-fix suggestions in the context actions menu, even if the corresponding rule is enabled. This is unfortunate, because even if one does not want a rule to be auto-fixed in the background when saving/reformatting, it is still reasonable that one would like to manually apply the auto-fix on a case-by-case basis using the context action menu.

Suggestion

My opinionated suggestion would be to simply ignore the fixable and unfixable settings for the context action menu. The argument is that offering a context action fix is pretty unobtrusive and, considering that a user chose to enable a given rule in the first place, they probably also would occasionally want to apply an existing auto-fix (even if they don't want to do so automatically).

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@urob
Copy link
Author

urob commented Aug 29, 2023

Do the automatic background formatting and the context action use the same ruff process behind the scenes, or are they generated using different processes? If the latter, it seems that adding the fixable=ALL CLI option to the process that generates the context actions might do the trick? Perhaps one could make this optional with a "overwrite fixable for context actions" setting?

@koxudaxi
Copy link
Owner

I'm sorry my late reply.
The plugin calls ruff command every time. It means ruff uses configs on pyproejct.toml.
Also, the entry point is individual we can add specific an argument per plugin feature.

@urob
Copy link
Author

urob commented Sep 20, 2023

Perhaps the easiest/most flexible approach would be to add options to add custom CLI options to ruff for the different entry points? (context action menu, auto fix on format/save)

This way the issue described here could be addressed by the user by adding fixable=ALL to the context action instances of ruff. Someone else could decide to overwrite the default pyproject.toml for the auto fix on format, or use the feature to configure ruff as suggested in #135.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request polar
Projects
None yet
Development

No branches or pull requests

2 participants