-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add Ability to Output to Multiple Files/Formats #21633
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
base: main
Are you sure you want to change the base?
Add Ability to Output to Multiple Files/Formats #21633
Conversation
|
Have to added context: GitLab comment code in PR only for the most expensive subscription and not all developers immediately rushing to read CodeQuality report. |
|
I'd like to explore some more designs on the CLI argument. I don't think what's recommended in this PR has good ergonomics. E.g. some alternatives:
What bothers me a bit is that Have you looked at what other tools do (not just pylint)? For example, this is what vitest does: golang CLI We might also be able to get away with something easier because what I understand is that this is a CI specific issue and the only thing people need is to allow one output file, but keeping the default CLI output. I didn't see any request where someone actually wants to write 3 outputs at once. |
Yeah, the main use case here is to produce two outputs, a human-readable ( What do you think of an approach where we tweak the behavior to always produce a human-readable report in the console? The invocation might be akin to: We could also introduce a new console format to disable reporting findings out to the console, should that behavior be desired. Thus we'd have a few different options for this proposed The minor downside here is that we're introducing new parameters and we'd probably want to deprecate the old ones if we're to use something like this. |
|
I'd prefer not to introduce new parameters if possible. I also think that |
|
It might be worth taking a look at what basedpyright does here https://docs.basedpyright.com/latest/benefits-over-pyright/improved-ci-integration/ We also discussed in the past to automatically change the behavior based on wheter we dedect that ruff runs in CI (where the CI variable is set) |
Summary
I have written many CI jobs where Ruff outputs in the GitLab format to a file, but this suppresses outputting to
stdout/stderr. If Ruff finds an issue this will fail the CI job and it won't be immediately obvious to the developer what the lint finding was -- they'd have to go and crack open the GitLab JSON artifact, or view it in GitLab's merge request view.This change allows us to write both a machine-readable artifact (e.g. GitLab JSON format) as well as output Ruff's findings in a human-readable format without needing to run it twice.
This PR should resolve #2388.
Test Plan
Tested locally, and hopefully tests will also be run in a CI pipeline.