Skip to content

Commit 12ce445

Browse files
authored
[ty] Document configuration schema (#17950)
1 parent f46ed8d commit 12ce445

File tree

26 files changed

+710
-93
lines changed

26 files changed

+710
-93
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exclude: |
55
.github/workflows/release.yml|
66
crates/ty_vendored/vendor/.*|
77
crates/ty_project/resources/.*|
8+
crates/ty/docs/configuration.md|
89
crates/ty/docs/rules.md|
910
crates/ruff_benchmark/resources/.*|
1011
crates/ruff_linter/resources/.*|

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ruff_index = { path = "crates/ruff_index" }
2323
ruff_linter = { path = "crates/ruff_linter" }
2424
ruff_macros = { path = "crates/ruff_macros" }
2525
ruff_notebook = { path = "crates/ruff_notebook" }
26+
ruff_options_metadata = { path = "crates/ruff_options_metadata" }
2627
ruff_python_ast = { path = "crates/ruff_python_ast" }
2728
ruff_python_codegen = { path = "crates/ruff_python_codegen" }
2829
ruff_python_formatter = { path = "crates/ruff_python_formatter" }
@@ -182,7 +183,7 @@ wild = { version = "2" }
182183
zip = { version = "0.6.6", default-features = false }
183184

184185
[workspace.metadata.cargo-shear]
185-
ignored = ["getrandom"]
186+
ignored = ["getrandom", "ruff_options_metadata"]
186187

187188

188189
[workspace.lints.rust]

crates/ruff/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ruff_graph = { workspace = true, features = ["serde", "clap"] }
2020
ruff_linter = { workspace = true, features = ["clap"] }
2121
ruff_macros = { workspace = true }
2222
ruff_notebook = { workspace = true }
23+
ruff_options_metadata = { workspace = true, features = ["serde"] }
2324
ruff_python_ast = { workspace = true }
2425
ruff_python_formatter = { workspace = true }
2526
ruff_python_parser = { workspace = true }

crates/ruff/src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ use ruff_linter::settings::types::{
2222
PythonVersion, UnsafeFixes,
2323
};
2424
use ruff_linter::{RuleParser, RuleSelector, RuleSelectorParser};
25+
use ruff_options_metadata::{OptionEntry, OptionsMetadata};
2526
use ruff_python_ast as ast;
2627
use ruff_source_file::{LineIndex, OneIndexed, PositionEncoding};
2728
use ruff_text_size::TextRange;
2829
use ruff_workspace::configuration::{Configuration, RuleSelection};
2930
use ruff_workspace::options::{Options, PycodestyleOptions};
30-
use ruff_workspace::options_base::{OptionEntry, OptionsMetadata};
3131
use ruff_workspace::resolver::ConfigurationTransformer;
3232
use rustc_hash::FxHashMap;
3333
use toml;

crates/ruff/src/commands/completions/config.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use clap::builder::{PossibleValue, TypedValueParser, ValueParserFactory};
22
use itertools::Itertools;
33
use std::str::FromStr;
44

5-
use ruff_workspace::{
6-
options::Options,
7-
options_base::{OptionField, OptionSet, OptionsMetadata, Visit},
8-
};
5+
use ruff_options_metadata::{OptionField, OptionSet, OptionsMetadata, Visit};
6+
use ruff_workspace::options::Options;
97

108
#[derive(Default)]
119
struct CollectOptionsVisitor {

crates/ruff/src/commands/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use anyhow::{anyhow, Result};
22

33
use crate::args::HelpFormat;
44

5+
use ruff_options_metadata::OptionsMetadata;
56
use ruff_workspace::options::Options;
6-
use ruff_workspace::options_base::OptionsMetadata;
77

88
#[expect(clippy::print_stdout)]
99
pub(crate) fn config(key: Option<&str>, format: HelpFormat) -> Result<()> {

crates/ruff_dev/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ruff_diagnostics = { workspace = true }
1717
ruff_formatter = { workspace = true }
1818
ruff_linter = { workspace = true, features = ["schemars"] }
1919
ruff_notebook = { workspace = true }
20+
ruff_options_metadata = { workspace = true }
2021
ruff_python_ast = { workspace = true }
2122
ruff_python_codegen = { workspace = true }
2223
ruff_python_formatter = { workspace = true }

crates/ruff_dev/src/generate_all.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use anyhow::Result;
44

55
use crate::{
6-
generate_cli_help, generate_docs, generate_json_schema, generate_ty_rules, generate_ty_schema,
6+
generate_cli_help, generate_docs, generate_json_schema, generate_ty_options, generate_ty_rules,
7+
generate_ty_schema,
78
};
89

910
pub(crate) const REGENERATE_ALL_COMMAND: &str = "cargo dev generate-all";
@@ -40,6 +41,7 @@ pub(crate) fn main(args: &Args) -> Result<()> {
4041
generate_docs::main(&generate_docs::Args {
4142
dry_run: args.mode.is_dry_run(),
4243
})?;
44+
generate_ty_options::main(&generate_ty_options::Args { mode: args.mode })?;
4345
generate_ty_rules::main(&generate_ty_rules::Args { mode: args.mode })?;
4446
Ok(())
4547
}

crates/ruff_dev/src/generate_docs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use strum::IntoEnumIterator;
1313

1414
use ruff_diagnostics::FixAvailability;
1515
use ruff_linter::registry::{Linter, Rule, RuleNamespace};
16+
use ruff_options_metadata::{OptionEntry, OptionsMetadata};
1617
use ruff_workspace::options::Options;
17-
use ruff_workspace::options_base::{OptionEntry, OptionsMetadata};
1818

1919
use crate::ROOT_DIR;
2020

crates/ruff_dev/src/generate_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use itertools::Itertools;
55
use std::fmt::Write;
66

7+
use ruff_options_metadata::{OptionField, OptionSet, OptionsMetadata, Visit};
78
use ruff_python_trivia::textwrap;
89
use ruff_workspace::options::Options;
9-
use ruff_workspace::options_base::{OptionField, OptionSet, OptionsMetadata, Visit};
1010

1111
pub(crate) fn generate() -> String {
1212
let mut output = String::new();

crates/ruff_dev/src/generate_rules_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use strum::IntoEnumIterator;
1111
use ruff_diagnostics::FixAvailability;
1212
use ruff_linter::registry::{Linter, Rule, RuleNamespace};
1313
use ruff_linter::upstream_categories::UpstreamCategoryAndPrefix;
14+
use ruff_options_metadata::OptionsMetadata;
1415
use ruff_workspace::options::Options;
15-
use ruff_workspace::options_base::OptionsMetadata;
1616

1717
const FIX_SYMBOL: &str = "🛠️";
1818
const PREVIEW_SYMBOL: &str = "🧪";

0 commit comments

Comments
 (0)