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

Implement --extend-fixable and --extend-unfixable variants in CLI #4289

Closed
ljnsn opened this issue May 8, 2023 · 3 comments · Fixed by #4297
Closed

Implement --extend-fixable and --extend-unfixable variants in CLI #4289

ljnsn opened this issue May 8, 2023 · 3 comments · Fixed by #4297
Assignees
Labels
configuration Related to settings and configuration

Comments

@ljnsn
Copy link

ljnsn commented May 8, 2023

Consider the following ruff config:

[tool.ruff]
fix = true
unfixable = ["F401", "F841"]

F401 and F841 are added as unfixable so that ruff doesn't automatically remove violating lines on file save (it's set up in the editor for autoformat). I do want to enable them in my pre-commit config though. So what I have done is configure the ruff hook like so:

      - id: ruff
        name: ruff
        entry: ruff
        args: ["--fixable=F401,F841"]
        require_serial: true
        language: system
        types: [python]

However, this makes ruff consider only those two codes as fixable. So I thought I could fix it by passing --unfixable=E501, for example, assuming that would override the value set in the ruff config. The doesn't seem to be the case though, ruff still does not fix the errors.

This does not depend on pre-commit btw, the same can be reproduced by just running ruff from CLI. Essentially, I'm looking for a way to overwrite unfixable, without using --isolated, because there is more config than the minimal example above.

Is there a generally recommended way to do this?

@charliermarsh
Copy link
Member

I would've expected --unfixable=E501 to work. As a hacky workaround, could you try --fixable=ALL,F401,F841? If we add --extend-fixable, as requested today (hah) in #4272, then --extend-fixable=F401,F841 would also work.

@charliermarsh charliermarsh added the configuration Related to settings and configuration label May 8, 2023
@ljnsn
Copy link
Author

ljnsn commented May 8, 2023

Thanks for the quick answer. It's not a coincidence, #4272 was opened by a colleague of mine, but I didn't know about it until now 😄

Your suggested workaround works, it's even sufficient to pass --fixable=ALL. An extend-fixable would be great though.

@charliermarsh
Copy link
Member

Oh, hah, that's funny :)

I'll keep this open to track --extend-fixable, it really should exist to mirror the --extend-select variants.

@charliermarsh charliermarsh changed the title How to overwrite unfixable set in config file? Implement --extend-fixable and --extend-unfixable variants in CLI May 8, 2023
@charliermarsh charliermarsh self-assigned this May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants