Skip to content

Commit 87443e6

Browse files
not-my-profilecharliermarsh
authored andcommitted
Support prefix "PL" to select all of Pylint
1 parent 16d2ceb commit 87443e6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ruff.schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,7 @@
15541554
"PIE8",
15551555
"PIE80",
15561556
"PIE807",
1557+
"PL",
15571558
"PLC",
15581559
"PLC0",
15591560
"PLC04",

ruff_macros/src/rule_code_prefix.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn expand<'a>(
9494
let mut prefix_to_codes: BTreeMap<String, BTreeSet<String>> = BTreeMap::default();
9595

9696
let mut all_codes = BTreeSet::new();
97+
let mut pl_codes = BTreeSet::new();
9798

9899
for variant in variants {
99100
let code_str = variant.to_string();
@@ -109,10 +110,14 @@ pub fn expand<'a>(
109110
.or_default()
110111
.insert(code_str.clone());
111112
}
113+
if code_str.starts_with("PL") {
114+
pl_codes.insert(code_str.to_string());
115+
}
112116
all_codes.insert(code_str);
113117
}
114118

115119
prefix_to_codes.insert(ALL.to_string(), all_codes);
120+
prefix_to_codes.insert("PL".to_string(), pl_codes);
116121

117122
// Add any prefix aliases (e.g., "U" to "UP").
118123
for (alias, rule_code) in PREFIX_REDIRECTS.iter() {
@@ -150,6 +155,7 @@ pub fn expand<'a>(
150155
Two,
151156
Three,
152157
Four,
158+
Five,
153159
}
154160

155161
#[derive(
@@ -217,13 +223,17 @@ fn generate_impls<'a>(
217223
#prefix_ident::#prefix => SuffixLength::None,
218224
}
219225
} else {
220-
let num_numeric = prefix_str.chars().filter(|char| char.is_numeric()).count();
226+
let mut num_numeric = prefix_str.chars().filter(|char| char.is_numeric()).count();
227+
if prefix_str != "PL" && prefix_str.starts_with("PL") {
228+
num_numeric += 1;
229+
}
221230
let suffix_len = match num_numeric {
222231
0 => quote! { SuffixLength::Zero },
223232
1 => quote! { SuffixLength::One },
224233
2 => quote! { SuffixLength::Two },
225234
3 => quote! { SuffixLength::Three },
226235
4 => quote! { SuffixLength::Four },
236+
5 => quote! { SuffixLength::Five },
227237
_ => panic!("Invalid prefix: {prefix}"),
228238
};
229239
quote! {

src/settings/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ fn resolve_codes<'a>(specs: impl IntoIterator<Item = RuleCodeSpec<'a>>) -> FxHas
320320
SuffixLength::Two,
321321
SuffixLength::Three,
322322
SuffixLength::Four,
323+
SuffixLength::Five,
323324
] {
324325
for selector in spec.select {
325326
if selector.specificity() == specificity {

0 commit comments

Comments
 (0)