Skip to content

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 ty 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.

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 https://github.com/astral-sh/ruff/issues/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
ty 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