mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:51:25 +00:00
[red-knot] Resolve Options
to Settings
(#16000)
## Summary This PR generalize the idea that we may want to emit diagnostics for invalid or incompatible configuration values similar to how we already do it for `rules`. This PR introduces a new `Settings` struct that is similar to `Options` but, unlike `Options`, are fields have their default values filled in and they use a representation optimized for reads. The diagnostics created during loading the `Settings` are stored on the `Project` so that we can emit them when calling `check`. The motivation for this work is that it simplifies adding new settings. That's also why I went ahead and added the `terminal.error-on-warning` setting to demonstrate how new settings are added. ## Test Plan Existing tests, new CLI test.
This commit is contained in:
parent
524cf6e515
commit
678b0c2d39
13 changed files with 214 additions and 62 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![no_main]
|
||||
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
use std::sync::{Arc, Mutex, OnceLock};
|
||||
|
||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||
|
||||
|
@ -29,8 +29,8 @@ struct TestDb {
|
|||
files: Files,
|
||||
system: TestSystem,
|
||||
vendored: VendoredFileSystem,
|
||||
events: std::sync::Arc<Mutex<Vec<salsa::Event>>>,
|
||||
rule_selection: std::sync::Arc<RuleSelection>,
|
||||
events: Arc<Mutex<Vec<salsa::Event>>>,
|
||||
rule_selection: Arc<RuleSelection>,
|
||||
}
|
||||
|
||||
impl TestDb {
|
||||
|
@ -39,7 +39,7 @@ impl TestDb {
|
|||
storage: salsa::Storage::default(),
|
||||
system: TestSystem::default(),
|
||||
vendored: red_knot_vendored::file_system().clone(),
|
||||
events: std::sync::Arc::default(),
|
||||
events: Arc::default(),
|
||||
files: Files::default(),
|
||||
rule_selection: RuleSelection::from_registry(default_lint_registry()).into(),
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ impl SemanticDb for TestDb {
|
|||
!file.path(self).is_vendored_path()
|
||||
}
|
||||
|
||||
fn rule_selection(&self) -> &RuleSelection {
|
||||
&self.rule_selection
|
||||
fn rule_selection(&self) -> Arc<RuleSelection> {
|
||||
self.rule_selection.clone()
|
||||
}
|
||||
|
||||
fn lint_registry(&self) -> &LintRegistry {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue