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

Using ruff check diff suppresses errors #4093

Closed
aminalaee opened this issue Apr 25, 2023 · 7 comments · Fixed by #4098
Closed

Using ruff check diff suppresses errors #4093

aminalaee opened this issue Apr 25, 2023 · 7 comments · Fixed by #4098
Labels
cli Related to the command-line interface

Comments

@aminalaee
Copy link

aminalaee commented Apr 25, 2023

Hey, thanks for the great work.
I don't know if this is a bug or maybe unclear flag, but doing ruff check --diff . does not fail:

try:
    pass
except:
    pass

But running ruff check . shows proper errors:

E722 Do not use bare `except`

Is this expected? I didn't expect --diff to have this side-effect, maybe the help is not clear?

@JonathanPlasse
Copy link
Contributor

If the help of the CLI you can find

--diff Avoid writing any fixed files back; instead, output a diff for each changed file to stdout

--diff is to be used in conjunction with --fix.
Without --fix, it will always return nothing with exit code 0.

@aminalaee
Copy link
Author

Thanks for the clarification, that makes more sense now.
Maybe it might be a good idea to force this combination since without one it's not really doing much.

@dhruvmanila
Copy link
Member

I think updating the --help text to include this would help. Better option would be to exit with an appropriate message stating the usage of the flag (--diff is to be used in conjunction with --fix flag).

@aminalaee aminalaee reopened this Apr 25, 2023
@aminalaee
Copy link
Author

I just opened this so the maintainers can decide if it needs any action.
Thanks for the info.

@charliermarsh
Copy link
Member

@dhruvmanila - Agreed, would be nice if we could exit with a meaningful error there.

@charliermarsh charliermarsh added the cli Related to the command-line interface label Apr 25, 2023
@odie5533
Copy link

odie5533 commented Feb 1, 2024

Is there an option to output both diffs it could make as well as errors that don't have fixes? It would be useful for me to output all errors + all fixes and return code 1 if there are any.

@zanieb
Copy link
Member

zanieb commented Feb 1, 2024

Hey @odie5533 that should become the default ruff check behavior after #7352 — it's on our roadmap!

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants