diff --git a/ruff_dev/src/generate_check_code_prefix.rs b/ruff_dev/src/generate_check_code_prefix.rs index 719e49130b..abbb248115 100644 --- a/ruff_dev/src/generate_check_code_prefix.rs +++ b/ruff_dev/src/generate_check_code_prefix.rs @@ -130,6 +130,21 @@ pub fn main(cli: &Cli) -> Result<()> { output.push('\n'); output.push('\n'); output.push_str(&scope.to_string()); + output.push('\n'); + output.push('\n'); + + // Add the list of output categories (not generated). + output.push_str("pub const CATEGORIES: &[CheckCodePrefix] = &["); + output.push('\n'); + for prefix in prefix_to_codes.keys() { + if prefix.chars().all(char::is_alphabetic) { + output.push_str(&format!("CheckCodePrefix::{prefix},")); + output.push('\n'); + } + } + output.push_str("];"); + output.push('\n'); + output.push('\n'); // Write the output to `src/checks_gen.rs` (or stdout). if cli.dry_run { diff --git a/src/checks_gen.rs b/src/checks_gen.rs index b333442ff4..22718629fb 100644 --- a/src/checks_gen.rs +++ b/src/checks_gen.rs @@ -1603,3 +1603,25 @@ impl CheckCodePrefix { } } } + +pub const CATEGORIES: &[CheckCodePrefix] = &[ + CheckCodePrefix::A, + CheckCodePrefix::ANN, + CheckCodePrefix::B, + CheckCodePrefix::BLE, + CheckCodePrefix::C, + CheckCodePrefix::D, + CheckCodePrefix::E, + CheckCodePrefix::F, + CheckCodePrefix::FBT, + CheckCodePrefix::I, + CheckCodePrefix::M, + CheckCodePrefix::N, + CheckCodePrefix::Q, + CheckCodePrefix::RUF, + CheckCodePrefix::S, + CheckCodePrefix::T, + CheckCodePrefix::U, + CheckCodePrefix::W, + CheckCodePrefix::YTT, +]; diff --git a/src/settings/configuration.rs b/src/settings/configuration.rs index 324ec8a93b..8e5ac386e4 100644 --- a/src/settings/configuration.rs +++ b/src/settings/configuration.rs @@ -9,7 +9,7 @@ use once_cell::sync::Lazy; use path_absolutize::path_dedot; use regex::Regex; -use crate::checks_gen::CheckCodePrefix; +use crate::checks_gen::{CheckCodePrefix, CATEGORIES}; use crate::settings::pyproject::load_options; use crate::settings::types::{FilePattern, PerFileIgnore, PythonVersion}; use crate::{ @@ -117,28 +117,7 @@ impl Configuration { .unwrap_or_else(|| vec![CheckCodePrefix::E, CheckCodePrefix::F]), extend_select: options.extend_select.unwrap_or_default(), fix: options.fix.unwrap_or_default(), - fixable: options.fixable.unwrap_or_else(|| { - // TODO(charlie): Autogenerate this list. - vec![ - CheckCodePrefix::A, - CheckCodePrefix::B, - CheckCodePrefix::BLE, - CheckCodePrefix::C, - CheckCodePrefix::D, - CheckCodePrefix::E, - CheckCodePrefix::F, - CheckCodePrefix::I, - CheckCodePrefix::M, - CheckCodePrefix::N, - CheckCodePrefix::Q, - CheckCodePrefix::RUF, - CheckCodePrefix::S, - CheckCodePrefix::T, - CheckCodePrefix::U, - CheckCodePrefix::W, - CheckCodePrefix::YTT, - ] - }), + fixable: options.fixable.unwrap_or_else(|| CATEGORIES.to_vec()), unfixable: options.unfixable.unwrap_or_default(), ignore: options.ignore.unwrap_or_default(), line_length: options.line_length.unwrap_or(88),