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

[red-knot] Support --exit-zero and --error-on-warning #15746

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo commented Jan 26, 2025

Summary

Resolves #15500, resolves #15501.

Red Knot now accepts --exit-zero and --error-on-warning as CLI flags. The following table summarizes their effect on the exit code:

Output No errors At least one warning At least one error Panic
Default 0 0 1 2
--exit-zero 0 0 0 2
--error-on-warning 0 1 1 2

Test Plan

Unit tests.

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Jan 26, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We can't use self.cli_options in main_loop. We instead need to use project.options (ideally settings) to respect the same value being set in a configuration file.

crates/red_knot_project/src/metadata/options.rs Outdated Show resolved Hide resolved
crates/red_knot/src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great.

I decided to revert the Options changes again and add configuration support as part of #15491. The reason I reverted is mainly that we shouldn't use Options outside the "reading and merging the configuration" phase. We should introduce a dedicated Settings struct, similar to what we have in Ruff, that stores the resolved Options (with defaults filled in)

@MichaReiser MichaReiser enabled auto-merge (squash) February 3, 2025 07:31
@MichaReiser MichaReiser merged commit 30d5e9a into astral-sh:main Feb 3, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the rk-cli-exit-codes branch February 3, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[red-knot]: --error-on-warning=<bool> [red-knot] --exit-zero
3 participants