[pylint] Implement too-many-public-methods rule (PLR0904) (#6179)

Implement
https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/too-many-public-methods.html

Confusingly the rule page mentions a max of 7 while in practice it is
20.
https://github.com/search?q=repo%3Apylint-dev%2Fpylint+max-public-methods&type=code

## Summary

Implement pylint's R0904

## Test Plan

Unit tests.
This commit is contained in:
Jelle van der Waa 2023-09-14 02:52:26 +02:00 committed by GitHub
parent 36fa1fe359
commit 04183b0299
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 283 additions and 2 deletions

View file

@ -2155,6 +2155,13 @@ pub struct PylintOptions {
/// Maximum number of statements allowed for a function or method body (see:
/// `PLR0915`).
pub max_statements: Option<usize>,
#[option(
default = r"20",
value_type = "int",
example = r"max-public-methods = 20"
)]
/// Maximum number of public methods allowed for a class (see: `PLR0904`).
pub max_public_methods: Option<usize>,
}
impl PylintOptions {
@ -2168,6 +2175,9 @@ impl PylintOptions {
max_returns: self.max_returns.unwrap_or(defaults.max_returns),
max_branches: self.max_branches.unwrap_or(defaults.max_branches),
max_statements: self.max_statements.unwrap_or(defaults.max_statements),
max_public_methods: self
.max_public_methods
.unwrap_or(defaults.max_public_methods),
}
}
}