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

Formatter: include filenames in ruff format --check #7782

Closed
matt-gardner opened this issue Oct 3, 2023 · 4 comments · Fixed by #7788
Closed

Formatter: include filenames in ruff format --check #7782

matt-gardner opened this issue Oct 3, 2023 · 4 comments · Fixed by #7788
Assignees
Labels
cli Related to the command-line interface formatter Related to the formatter

Comments

@matt-gardner
Copy link

Apologies if this is a duplicate or already fixed; the closest issue I found to this one was #7231. This issue is similar, but much smaller scoped. When I run black --check, it gives me a list of filenames that would be reformatted, not just a count. When I run ruff format --check, it only gives me statistics. The list of filenames is much more useful when the format check is run during CI, and it'd be nice to add it to ruff.

I'm running ruff 0.0.291. Here's a sample output from black and from ruff:

~/my_code % ruff format --check .
warning: `ruff format` is a work-in-progress, subject to change at any time, and intended only for experimentation.
5 files would be reformatted, 264 files left unchanged
~/my_code % black --check .         
would reformat /path/to/my_code/my_file.py

Oh no! 💥 💔 💥
1 file would be reformatted, 268 files would be left unchanged.
@charliermarsh charliermarsh added cli Related to the command-line interface formatter Related to the formatter labels Oct 3, 2023
@charliermarsh
Copy link
Member

Good call, we should fix this!

@charliermarsh charliermarsh added this to the Formatter: Beta milestone Oct 3, 2023
@charliermarsh charliermarsh self-assigned this Oct 3, 2023
charliermarsh added a commit that referenced this issue Oct 3, 2023
## Summary

We now list each changed file when running with `--check`.

Closes #7782.

## Test Plan

```
❯ cargo run -p ruff_cli -- format foo.py --check
   Compiling ruff_cli v0.0.292 (/Users/crmarsh/workspace/ruff/crates/ruff_cli)
rgo +    Finished dev [unoptimized + debuginfo] target(s) in 1.41s
     Running `target/debug/ruff format foo.py --check`
warning: `ruff format` is a work-in-progress, subject to change at any time, and intended only for experimentation.
Would reformat: foo.py
1 file would be reformatted
```
@matt-gardner
Copy link
Author

Awesome, thanks!

@charliermarsh
Copy link
Member

No prob, thanks for reporting.

@AdrianB-sovo
Copy link

@charliermarsh It would also be useful to have that when running it without --check (or at least allow to enable it with an option).
Usecase: I use the pre-commit config to run Ruff locally before each commit, but also on the CI (for all files).

  • Locally, I want to automatically change the files with the formatter on a commit.
  • In the CI, I want to see what files are not correctly formatted.

And thanks for the amazing tools (Ruff and uv) @charliermarsh! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface formatter Related to the formatter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants