[pylint] Add allow-dunder-method-names setting for bad-dunder-method-name (PLW3201) (#8812)

closes #8732

I noticed that the reference to the setting in the rule docs doesn't
work, but there seem to be something wrong with pylint settings in
general in the docs - the "For related settings, see ...." is also
missing there.
This commit is contained in:
Adrian 2023-11-22 00:44:23 +01:00 committed by GitHub
parent f1ed0f27c2
commit 948094e691
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 3 deletions

View file

@ -2573,6 +2573,17 @@ pub struct PylintOptions {
)]
pub allow_magic_value_types: Option<Vec<ConstantType>>,
/// Dunder methods name to allow, in addition to the default set from the
/// Python standard library (see: `PLW3201`).
#[option(
default = r#"[]"#,
value_type = r#"list[str]"#,
example = r#"
allow-dunder-method-names = ["__tablename__", "__table_args__"]
"#
)]
pub allow_dunder_method_names: Option<FxHashSet<String>>,
/// Maximum number of branches allowed for a function or method body (see:
/// `PLR0912`).
#[option(default = r"12", value_type = "int", example = r"max-branches = 12")]
@ -2614,6 +2625,7 @@ impl PylintOptions {
allow_magic_value_types: self
.allow_magic_value_types
.unwrap_or(defaults.allow_magic_value_types),
allow_dunder_method_names: self.allow_dunder_method_names.unwrap_or_default(),
max_args: self.max_args.unwrap_or(defaults.max_args),
max_bool_expr: self.max_bool_expr.unwrap_or(defaults.max_bool_expr),
max_returns: self.max_returns.unwrap_or(defaults.max_returns),