You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Frank Epperlein, Sergio Castillo, Jack McIvor, 93578237, Avasam, Sebastian Weigand, Fidel Ramos, Patrick Roddy, Tobias Hernstig, Tyler C Laprade, CFA and 340 more
Reacted by vivodi
Reacted by Brian Westphal
Reacted by Brian Westphal, Candido Sales Gomes and Rudi Kershaw
Reacted by vivodi
Reacted by Tyler C Laprade, CFA, Stanislav Zmiev, Evan Chen, Joshua Sleeper, Somraj Saha, Malte Swart, Jasper Poppe, Peter Hoburg, Will Gordon, Diogo and 26 more
Reacted by Simon Lemieux, Will Gordon, Diogo, Richard Höchenberger, Rahul Kumar, Anas, Daniel Salazar, Thayne McCombs, Ingo Marquardt, Pratik Borole and 5 more
Reacted by Anton Buyskikh, Rahul Kumar, Éloi Rivard, Anas, Thayne McCombs, Michal Pstrag, Pratik Borole, Gui, RubenBZonneplan, Brian Westphal and 2 more
Roughly, one proposed interface would be the generalization of ruff check and the addition of flags such as --lint / --no-lint and --format / --no-format to enable specific tools. These flags would also be configurable in the settings as ruff.check.lint and ruff.check.format (or ruff.lint.enabled and ruff.format.enabled).
On ruff check --format, unformatted files would be flagged as a violations (similar to lint rule violations).
On ruff check --format --fix, unformatted files would be formatted.
Further configuration of each tool would be done from the respective ruff.lint and lint.format sections.
I believe, eventually, it would be ideal for --format (and any other future tools) to be enabled by default when running ruff check.
This approach would require significant consideration of our existing check diagnostic and violation design, as it is very lint focused at the moment. Consideration should be made for the possibility of future tools that would raise diagnostics, such as a type checker.
It's an open question whether a dedicated ruff lint command would be added.
Reacted by Tyler C Laprade, CFA, Asuka Minato, Jason, Thayne McCombs, Dan Raviv, Harald, jn64, Maximilian Wolf and bess
If you ask me about how to join into one command, my answer (and I think most of users) would be put formatter as a lint rule.
Like #7310 (reply in thread), in my opinion formatter actually is linter rule(s) with safe-autofix: ruff check . --select E,FMT --fix
@zanieb I'm pretty sure you also considered this, but I didn't find why you ignored this approach. Can you show what are blockers for this design? solving those blockers maybe less expensive for team (and users)?
For now, I think --add-noqa (and --watch?) won't work as desired on this approach.
We discussed this internally. Building the formatter as a linter raised a couple of design questions:
* The formatter would need to support `noqa` suppression comments
Isn't that the job of the linting mechanism that works based on whether the formatting check would find anything.. How does this work for I001 (isort)?
* The `CLI` would be fundamentally different from how editors work where editors use different commands for formatting and linting.
I feel it makes sense to keep formatting also as a separate command for these use cases
* How would we support enabling preview style formatting for the formatter without enabling preview behavior of other lint rules.
Make it two different rules? You can even (if not configured explicit) enable the preview rule in preview and disable the normal formatting rule...
Overall, formatting just felt different enough.
I kind of disagree. But if it is, import sorting also falls in this category...
I kind of disagree. But if it is, import sorting also falls in this category...
We are also of the opinion that import sorting is not well suited to be a lint rule. We are still trying to figure out the best way to resolve that.
Add format-preview and lint-preview...
We already have this as ruff.lint.preview and ruff.format.preview. If the formatter is implemented as a lint rule then it would be confusing that it's unaffected by lint.preview though.
I was originally a strong proponent of using a lint code for the formatter. Here are some notes:
A new formatting lint category i.e. FMT. Formatter violations could be implemented as rules e.g.
FMT001 file would be formatted
FMT002 invalid placement of fmt pragma
Some thoughts:
Avoids collision with --format <style>
Simple integration with existing CLI
Does it make sense to have more than one format code?
How does this interact with existing linter noqa pragmas?
Can users ignore individual format violation codes?
Can we feasibly split formatting into discrete pieces?
Avoids adding new options to the CLI
Formatter violations are not special-cased
A file requiring formatting would not work well with our current diagnostic system
Harder to discover, i.e. --extend-select FMT is not intuitive
However, users are likely to be using ruff format separately when getting started
However, if formatting is on by default in the future then opt-out with --ignore FMT is simple
Easy for us to add this to the default rule set in the future
The problem with this approach is that there are many special cases where the formatter does not behave like a lint rule. While it's feasible to just push the formatter into the linter, we want to do better.
Reacted by T-256, Micha Reiser, 93578237, Tyler C Laprade, CFA and Alexander Beedie
FWIW, the way I use ruff is wrapped in 2 commands:
The lint command which runs:
ruff check --show-source --show-fixes ...
black --check --diff --quiet ...
# and other commands for other languages than python
I use this in CI for example.
I guess I could have used check too but it predates my use of ruff (and I kinda like lint as an intent to verify the code, not act on it, it's a read-only/safe command always).
The fix command which runs:
ruff check --fix-only --select F401,I001 ...
black ...
# and other commands for other languages than python
I use this when I want to cleanup my code, e.g. before commit.
I like that fix is a top level command instead of a check option, because checking and fixing are different intentions IMHO.
But I also combines the 2 commands often, where I fix then lint all at once.
I say this because a top-level fix command that do formatting + autofixing of lint issues is maybe less weird than check --fix --format, it's easy to type/remember.
I also have a long proposal adding a ruff fix command to resolve some of the awkwardness of putting everything in check — it's hard to be certain it will be worth the investment though. I'm glad to hear you think it'd be helpful!
I think regardless there needs to be a way for ruff check to indicate when files are not formatted.
Reacted by Jaap Roes, Tyler C Laprade, CFA, Thomas Heavey and Stanislav Zmiev (Stas)
@zanieb I believe ruff check should be deprecated altogether, and you should use ruff fix to do both ruff format and ruff lint ---fix (#8535). With the caveat that it is clearly documented that since ruff fix would do ruff lint --fix, it could be a potentially dangerous operation if the lint changes are not reviewed.
(Maybe there is a better term then both ruff check and ruff fix we have not thought of?)
@zanieb Did you discuss whether this unified command will be implemented in the near future? I am asking because I am considering merging python-lsp/python-lsp-ruff#57 as an intermediary solution.
Came back to use Python, obviously went for Ruff, still surprised this has not been prioritized. It feels like such a core usability "issue" that it should get some love. ruff check is hard to understand for new users. Notice how the help output does not say anything about lint in the output for these:
> ruff --help
...
Commands:
check Run Ruff on the given files or directories
format Run the Ruff formatter on the given files or directories
I still think, as suggested before in this thread, it is more idiomatic if we had this instead:
Commands:
check Run the Ruff linter and formatter on the given files or directories
format Run the Ruff formatter on the given files or directories
lint Run the Ruff linter on the given files or directories
This also correlates better with what the names are in pyproject.toml:
[tool.ruff.lint]
[tool.ruff.format]
I do understand there are a huge number of issues to work on here, but to me Ruff was born out of DX necessity, and isn't this kind of the number one DX issue any developer would have? To me it feels like a top priority to give back that DX love that Ruff and Astral were born from.
Reacted by Domen Jurkovic, Kent Matsuura, Ludovic Ortega, Jaap Roes, GregorE, Somraj Saha, Ville Säävuori, ExoticGamerrrYT, Charles de Beauchesne, Antony Milne and 13 more
@thernstig we agree with you that this feature is a huge DX improvement and it's very high up on the list of features we want to implement.
Reacted by Avasam, Charles de Beauchesne, Tobias Hernstig, Joffrey Bluthé, Kent Matsuura, Richard Höchenberger, Sebastian Weigand, karb94, Jonathon Reinhart, Lorenzo Panieri and 1 more
@thernstig I agree with everything you wrote except for one small detail regarding the wording in your proposal:
Commands:
check Run the Ruff linter and formatter on the given files or directories
format Run the Ruff formatter on the given files or directories
lint Run the Ruff linter on the given files or directories
The word "check" would seem to imply that the command only checks the formatting (ruff format --check), i.e. leave the files untouched, not actually run the formatter on the files in the sense of reformatting them. So "check" and "Run the Ruff […] formatter" are somewhat at odds with one another here.
The currently implemented commands format and check reflect this interpretation, too: format is the "destructive" operation, format --check the non-destructive (read-only) one. Meanwhile, check (= lint) is non-destructive, and check --fix is destructive.
Having fixed that and continuing your proposal, ruff check --fix could be the combined destructive operation ruff check --fix && ruff format that both auto-fixes linter errors, re-formats files as needed and produces an error if any errors could not be fixed. (Though, personally, I think a shortcut ruff fix would be great here, since ruff check --fix && ruff format is probably the command I invoke the most.)
EDIT: Fixed the order of ruff check --fix and ruff format. Thanks for pointing this out, @graipher!
Reacted by Niklas Jansen, Thayne McCombs, T-256, Ihor Aleksandrov, Matt Norton, Guilherme Silva, Anton Gilgur and Johnny Arcitec
@codethief I agree with everything you wrote except for one small detail.
You might want to reverse the order in which you are invoking the two commands, since a fix from check might make it so that a format is needed again, while the other way around is (probably) less likely.
Reacted by codethief, Thayne McCombs, Avasam, GregorE, Guilherme Silva and Nicky McCurdy
Activity
zanieb commentedon Oct 25, 2023
Roughly, one proposed interface would be the generalization of
ruff checkand the addition of flags such as--lint/--no-lintand--format/--no-formatto enable specific tools. These flags would also be configurable in the settings asruff.check.lintandruff.check.format(orruff.lint.enabledandruff.format.enabled).On
ruff check --format, unformatted files would be flagged as a violations (similar to lint rule violations).On
ruff check --format --fix, unformatted files would be formatted.Further configuration of each tool would be done from the respective
ruff.lintandlint.formatsections.I believe, eventually, it would be ideal for
--format(and any other future tools) to be enabled by default when runningruff check.This approach would require significant consideration of our existing check diagnostic and violation design, as it is very lint focused at the moment. Consideration should be made for the possibility of future tools that would raise diagnostics, such as a type checker.
It's an open question whether a dedicated
ruff lintcommand would be added.T-256 commentedon Oct 26, 2023
If you ask me about how to join into one command, my answer (and I think most of users) would be put formatter as a lint rule.
Like #7310 (reply in thread), in my opinion formatter actually is linter rule(s) with safe-autofix:
ruff check . --select E,FMT --fix@zanieb I'm pretty sure you also considered this, but I didn't find why you ignored this approach. Can you show what are blockers for this design? solving those blockers maybe less expensive for team (and users)?
For now, I think
--add-noqa(and--watch?) won't work as desired on this approach.MichaReiser commentedon Oct 26, 2023
We discussed this internally. Building the formatter as a linter raised a couple of design questions:
noqasuppression commentsCLIwould be fundamentally different from how editors work where editors use different commands for formatting and linting.Overall, formatting just felt different enough.
hmvp commentedon Oct 26, 2023
Isn't that the job of the linting mechanism that works based on whether the formatting check would find anything.. How does this work for I001 (isort)?
I feel it makes sense to keep formatting also as a separate command for these use cases
Make it two different rules? You can even (if not configured explicit) enable the preview rule in preview and disable the normal formatting rule...
T-256 commentedon Oct 26, 2023
Thanks, I didn't realize these issues, here are my proposed solutions for them:
A. Use
#fmt:comments for formatting violations.B. We can warn
noqasuppression is not available for this rule.For formatting, editors can keep current behavior, also for linting and autofixes I don't think
FMTrequires any change to output structure.Add
format-previewandlint-preview. (--(no-)previewwill apply for both linter and formatter)zanieb commentedon Oct 26, 2023
We are also of the opinion that import sorting is not well suited to be a lint rule. We are still trying to figure out the best way to resolve that.
We already have this as
ruff.lint.previewandruff.format.preview. If the formatter is implemented as a lint rule then it would be confusing that it's unaffected bylint.previewthough.I was originally a strong proponent of using a lint code for the formatter. Here are some notes:
The problem with this approach is that there are many special cases where the formatter does not behave like a lint rule. While it's feasible to just push the formatter into the linter, we want to do better.
jaap3 commentedon Oct 27, 2023
I have no strong opinion, just fyi. I always used https://pypi.org/project/flake8-isort/ and https://pypi.org/project/flake8-black/. Basically the lining check for those plugins is "would isort or black make any changes?". To me that was good enough, never considered adding suppression comment (failure means, just run the formatter).
Sarcasm commentedon Oct 27, 2023
FWIW, the way I use ruff is wrapped in 2 commands:
The
lintcommand which runs:I use this in CI for example.
I guess I could have used
checktoo but it predates my use of ruff (and I kinda likelintas an intent to verify the code, not act on it, it's a read-only/safe command always).The
fixcommand which runs:I use this when I want to cleanup my code, e.g. before commit.
I like that
fixis a top level command instead of acheckoption, because checking and fixing are different intentions IMHO.But I also combines the 2 commands often, where I
fixthenlintall at once.I say this because a top-level
fixcommand that do formatting + autofixing of lint issues is maybe less weird thancheck --fix --format, it's easy to type/remember.zanieb commentedon Oct 27, 2023
I also have a long proposal adding a
ruff fixcommand to resolve some of the awkwardness of putting everything incheck— it's hard to be certain it will be worth the investment though. I'm glad to hear you think it'd be helpful!I think regardless there needs to be a way for
ruff checkto indicate when files are not formatted.thernstig commentedon Nov 8, 2023
@zanieb I believe
ruff checkshould be deprecated altogether, and you should useruff fixto do bothruff formatandruff lint ---fix(#8535). With the caveat that it is clearly documented that sinceruff fixwould doruff lint --fix, it could be a potentially dangerous operation if the lint changes are not reviewed.(Maybe there is a better term then both
ruff checkandruff fixwe have not thought of?)jhossbach commentedon Nov 15, 2023
@zanieb Did you discuss whether this unified command will be implemented in the near future? I am asking because I am considering merging python-lsp/python-lsp-ruff#57 as an intermediary solution.
zanieb commentedon Nov 15, 2023
@jhossbach I'd recommend moving forward with an intermediary solution as there's still quite a bit of work to be done on this issue.
30 remaining items
Makefile: Fix missing ruff format check
waynew commentedon Oct 9, 2025
FWIW I got tired of remembering this invocation, so I just wrote https://pypi.org/project/ruffup/ --
Silly? Maybe. Effective? Yes!
thernstig commentedon Apr 23, 2026
Came back to use Python, obviously went for Ruff, still surprised this has not been prioritized. It feels like such a core usability "issue" that it should get some love.
ruff checkis hard to understand for new users. Notice how the help output does not say anything about lint in the output for these:> ruff --help ... Commands: check Run Ruff on the given files or directories format Run the Ruff formatter on the given files or directoriesI still think, as suggested before in this thread, it is more idiomatic if we had this instead:
This also correlates better with what the names are in
pyproject.toml:I do understand there are a huge number of issues to work on here, but to me Ruff was born out of DX necessity, and isn't this kind of the number one DX issue any developer would have? To me it feels like a top priority to give back that DX love that Ruff and Astral were born from.
@zanieb thoughts?
MichaReiser commentedon Apr 23, 2026
@thernstig we agree with you that this feature is a huge DX improvement and it's very high up on the list of features we want to implement.
codethief commentedon Apr 24, 2026
@thernstig I agree with everything you wrote except for one small detail regarding the wording in your proposal:
The word "check" would seem to imply that the command only checks the formatting (
ruff format --check), i.e. leave the files untouched, not actually run the formatter on the files in the sense of reformatting them. So "check" and "Run the Ruff […] formatter" are somewhat at odds with one another here.The currently implemented commands
formatandcheckreflect this interpretation, too:formatis the "destructive" operation,format --checkthe non-destructive (read-only) one. Meanwhile,check(= lint) is non-destructive, andcheck --fixis destructive.Having fixed that and continuing your proposal,
ruff check --fixcould be the combined destructive operationruff check --fix && ruff formatthat both auto-fixes linter errors, re-formats files as needed and produces an error if any errors could not be fixed. (Though, personally, I think a shortcutruff fixwould be great here, sinceruff check --fix && ruff formatis probably the command I invoke the most.)EDIT: Fixed the order of
ruff check --fixandruff format. Thanks for pointing this out, @graipher!graipher commentedon Apr 25, 2026
@codethief I agree with everything you wrote except for one small detail.
You might want to reverse the order in which you are invoking the two commands, since a fix from
checkmight make it so that aformatis needed again, while the other way around is (probably) less likely.codethief commentedon Apr 25, 2026
😄
Thanks for pointing this out, I fixed it in my original comment!
Fix `format --check` spans for syntax errors (#27045)
Fix `format --check` spans for syntax errors (#27045)
Fix `format --check` spans for syntax errors (#27045)
Fix `format --check` spans for syntax errors (#27045)
Fix `format --check` spans for syntax errors (#27045)
itsvrushabh commentedon Oct 10, 2026