Skip to content

Commit

Permalink
many-to-one 7/9: Update JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
not-my-profile authored and charliermarsh committed Feb 14, 2023
1 parent c314e10 commit 849b947
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions crates/ruff/src/rule_redirects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> {

static REDIRECTS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
HashMap::from_iter([
("C", "C4"),
("C9", "C90"),
("T", "T10"),
("T1", "T10"),
("T2", "T20"),
// TODO(charlie): Remove by 2023-02-01.
("R", "RET"),
("R5", "RET5"),
Expand Down
19 changes: 14 additions & 5 deletions crates/ruff/src/rule_selector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::str::FromStr;

use itertools::Itertools;
use schemars::_serde_json::Value;
use schemars::schema::{InstanceType, Schema, SchemaObject};
use schemars::JsonSchema;
Expand Down Expand Up @@ -181,11 +182,19 @@ impl JsonSchema for RuleSelector {
instance_type: Some(InstanceType::String.into()),
enum_values: Some(
std::iter::once("ALL".to_string())
.chain(RuleCodePrefix::iter().map(|p| {
let prefix = p.linter().common_prefix();
let code = p.short_code();
format!("{prefix}{code}")
}))
.chain(
RuleCodePrefix::iter()
.map(|p| {
let prefix = p.linter().common_prefix();
let code = p.short_code();
format!("{prefix}{code}")
})
.chain(Linter::iter().filter_map(|l| {
let prefix = l.common_prefix();
(!prefix.is_empty()).then(|| prefix.to_string())
}))
.sorted(),
)
.map(Value::String)
.collect(),
),
Expand Down
5 changes: 0 additions & 5 deletions ruff.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@
"BLE0",
"BLE00",
"BLE001",
"C",
"C4",
"C40",
"C400",
Expand All @@ -1396,7 +1395,6 @@
"C415",
"C416",
"C417",
"C9",
"C90",
"C901",
"COM",
Expand Down Expand Up @@ -1939,11 +1937,8 @@
"SLF0",
"SLF00",
"SLF001",
"T",
"T1",
"T10",
"T100",
"T2",
"T20",
"T201",
"T203",
Expand Down

0 comments on commit 849b947

Please sign in to comment.