From e38a252bfc495ad335f6e273f50e47671bb1cba2 Mon Sep 17 00:00:00 2001 From: monosans Date: Mon, 10 Jul 2023 21:20:17 +0300 Subject: [PATCH] [`flake8-self`] Ignore `_name_` and `_value_` https://docs.python.org/3/library/enum.html#supported-sunder-names --- crates/ruff/src/rules/flake8_self/settings.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/ruff/src/rules/flake8_self/settings.rs b/crates/ruff/src/rules/flake8_self/settings.rs index 728b64c97c286..004815516dd0a 100644 --- a/crates/ruff/src/rules/flake8_self/settings.rs +++ b/crates/ruff/src/rules/flake8_self/settings.rs @@ -4,9 +4,18 @@ use serde::{Deserialize, Serialize}; use ruff_macros::{CacheKey, CombineOptions, ConfigurationOptions}; -// By default, ignore the `namedtuple` methods and attributes, which are underscore-prefixed to -// prevent conflicts with field names. -const IGNORE_NAMES: [&str; 5] = ["_make", "_asdict", "_replace", "_fields", "_field_defaults"]; +// By default, ignore the `namedtuple` methods and attributes, as well as the +// _sunder_ names in Enum, which are underscore-prefixed to prevent conflicts +// with field names. +const IGNORE_NAMES: [&str; 7] = [ + "_make", + "_asdict", + "_replace", + "_fields", + "_field_defaults", + "_name_", + "_value_", +]; #[derive( Debug, PartialEq, Eq, Serialize, Deserialize, Default, ConfigurationOptions, CombineOptions, @@ -19,7 +28,7 @@ const IGNORE_NAMES: [&str; 5] = ["_make", "_asdict", "_replace", "_fields", "_fi #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Options { #[option( - default = r#"["_make", "_asdict", "_replace", "_fields", "_field_defaults"]"#, + default = r#"["_make", "_asdict", "_replace", "_fields", "_field_defaults", "_name_", "_value_"]"#, value_type = "list[str]", example = r#" ignore-names = ["_new"]