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

CLI: Toggle default output format based on the number of violations #7353

Open
zanieb opened this issue Sep 13, 2023 · 3 comments
Open

CLI: Toggle default output format based on the number of violations #7353

zanieb opened this issue Sep 13, 2023 · 3 comments
Labels
cli Related to the command-line interface

Comments

@zanieb
Copy link
Member

zanieb commented Sep 13, 2023

In #7349 and #7352 the default output of ruff check includes much more content. However, this comes with a performance degradation for large numbers of violations as computing the display of source and fixes is expensive. A possible solution is to toggle the default output format between "full" and "concise" (#7350) depending on the number of detected violations. If we see more than 30 violations (for example), we should switch to the concise output. If --format full or --format concise is provided explicitly (or in the configuration file) we should always respect the given format regardless of the number of violations.

@zanieb zanieb added the cli Related to the command-line interface label Sep 13, 2023
@MichaReiser
Copy link
Member

If --format full or --format concise is provided explicitly (or in the configuration file) we should always respect the given format regardless of the number of violations.

I'm undecided on this. I think the use case here is that sometimes it's desired to get the full output, even if computing the output takes a long or prints a lot of text (e.g., when piping in CI). However, I'm concerned that the default full (no configuration) behavior is different from the explicit `output-format: full.

The main motivation for truncating fixes (we could, for example, print the first n violations in full, then print a message that Ruff has switched to concise) is to protect users from being overwhelmed and having a "slow" experience. I think I would want that protection even when I explicitly say that I want the full output format.

One less implicit solution would be to define a new full-always or similar output format.

@zanieb
Copy link
Member Author

zanieb commented Mar 30, 2024

I think I would want that protection even when I explicitly say that I want the full output format.

I don't really follow this, why? If you explicitly request the full format it seems weird that we would not respect that.

However, I'm concerned that the default full (no configuration) behavior is different from the explicit output-format: full.

We would encode the default behavior with a separate key like "auto" or "default" instead of overloading "full" to have two separate behaviors.

@MichaReiser
Copy link
Member

I don't really follow this, why? If you explicitly request the full format it seems weird that we would not respect that.

Because I understood that having the "automatic" output format (that switches between full and concise) and the "full" output format use the same configuration name. But that's not the case according to:

We would encode the default behavior with a separate key like "auto" or "default" instead of overloading "full" to have two separate behaviors.

So I'm okay with printing all diagnostics when explicitly requesting full (and not auto)

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

No branches or pull requests

2 participants