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

(🎁) Config options for specifying what gets run 'on save' #386

Open
KotlinIsland opened this issue Feb 29, 2024 · 3 comments
Open

(🎁) Config options for specifying what gets run 'on save' #386

KotlinIsland opened this issue Feb 29, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Feb 29, 2024

Currently, when enabled, the plugin will run format and check --fix on save, I want format to run, but not check --fix, or maybe I want check --fix but definitely not 'remove unused imports' (the absolute worst thing imaginable!)

Desired

config options for:

  • format on save
  • check --fix on save
  • organize imports on save
  • remove unused import on save

Additional

@koxudaxi koxudaxi added the enhancement New feature or request label Mar 27, 2024
@urob
Copy link

urob commented May 30, 2024

If you are fine with disabling autofixing imports all together, then adding the following to your pyproject.toml will do:

[tool.ruff.lint]
select = ['I']     # warn about unsorted imports
unfixable = ['I']  # but never fix them

The problem with that solution is that it also prevents you from manually triggering the sort via the context actions inside the IDE (c.f., #249 for a proposal that would fix this).

@KotlinIsland
Copy link
Contributor Author

@urob I don't cover unused import: https://docs.astral.sh/ruff/rules/unused-import/

Unfortunately, I do want unused imports to be removed, and I find it extremely valuable. But removing them on save is a nightmare, so your solution isn't relevant to me.

@urob
Copy link

urob commented May 31, 2024

@urob I don't cover unused import: https://docs.astral.sh/ruff/rules/unused-import/

Unfortunately, I do want unused imports to be removed, and I find it extremely valuable. But removing them on save is a nightmare, so your solution isn't relevant to me.

Isn't that precisely the caveat mentioned at the end of my comment and what #249 seeks to fix?

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

No branches or pull requests

3 participants