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

ruff format --check outputs "files left unchanged", which is slightly confusing #9132

Closed
johnthagen opened this issue Dec 14, 2023 · 5 comments · Fixed by #9153
Closed

ruff format --check outputs "files left unchanged", which is slightly confusing #9132

johnthagen opened this issue Dec 14, 2023 · 5 comments · Fixed by #9153
Labels
cli Related to the command-line interface good first issue Good for newcomers

Comments

@johnthagen
Copy link

johnthagen commented Dec 14, 2023

This is pretty minor, but when you run:

$ ruff format --check .
401 files left unchanged

It's slightly confusing to me that it says "files left unchanged", since in --check mode, it will never change any files. The first time I saw this, I thought I had accidentally forgotten to add the --check argument in a Nox session.

Would it be a small improvement if ruff format checked if it was in --check mode and changed the output to something like:

$ ruff format --check .
401 files checked successfully
$ ruff format --check .
Would reformat: main.py
1 file needs to be reformatted, 400 files checked successfully

Then again, maybe using the exact output from normal ruff format is better for consistency? No strong opinions from me, just an observation. Feel free to close if you disagree.

@zanieb
Copy link
Member

zanieb commented Dec 14, 2023

This makes sense to me! Thanks for raising.

@zanieb zanieb added good first issue Good for newcomers cli Related to the command-line interface labels Dec 14, 2023
@charliermarsh
Copy link
Member

Good call. Or "already formatted"? (Is that less clear?)

@johnthagen
Copy link
Author

@charliermarsh I like "already formatted" as well!

charliermarsh pushed a commit that referenced this issue Dec 18, 2023
…es (#9153)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

New messages for "format" mode. 
Fixes #9132 

## Test Plan

<!-- How was it tested? -->

I ran the tests specified in `CONTRIBUTING.md`
```bash
cargo run -p ruff_cli -- check /path/to/some_files.py --no-cache
cargo run -p ruff_cli -- format --check /path/to/some_files.py --no-cache

cargo clippy --workspace --all-targets --all-features -- -D warnings
RUFF_UPDATE_SCHEMA=1 cargo test
pre-commit run --all-files --show-diff-on-failure
```

**Note:** In case no files are detected, either correctly formatted,
changed, or unchanged, it does not display a message. Wouldn't it be
better to show some message in this case?
@Cherrymelon
Copy link

in version 0.7.2, type ruff format ./dataset/api.py still return 1 file left unchanged,
I think it need be update also

@MichaReiser
Copy link
Member

MichaReiser commented Nov 6, 2024

Looking at the PR, this seems intentional. See this comment, although I'm not sure why. @charliermarsh do you remember?

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 good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants