[flake8-bugbear] Implement class-as-data-structure (B903) (#9601)

## Summary

Adds `class-as-data-structure` rule (`B903`). Also compare pylint's `too-few-public-methods` (`PLR0903`).

Took some creative liberty with this by allowing the class to have any
decorators or base classes. There are years-old issues on pylint that
don't approve of the strictness when it comes to these things.

Especially considering that dataclass is a decorator and namedtuple _can
be_ a base class. I feel ignoring those explicitly is redundant all
things considered, but it's not a hill I'm willing to die on!

See: #970 

## Test Plan

`cargo test`

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: dylwil3 <dylwil3@gmail.com>
This commit is contained in:
Steve C 2025-01-06 22:18:28 -05:00 committed by GitHub
parent e7248ee43e
commit 78e26cec02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 305 additions and 1 deletions

View file

@ -1571,7 +1571,7 @@ mod tests {
const PREVIEW_RULES: &[Rule] = &[
Rule::ReimplementedStarmap,
Rule::SliceCopy,
Rule::TooManyPublicMethods,
Rule::ClassAsDataStructure,
Rule::TooManyPublicMethods,
Rule::UnnecessaryEnumerate,
Rule::MathConstant,