Thoughts on improving B902?
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 123
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 5
Description
I think B902 is great for detecting errors like this:
@classmethod
def foo(self):
...
However, I also find myself # noqa:ing it a bit too frequently. Here are some instances where I think it could be safely relaxed for everyone:
- Allow
_clsinstead ofcls(ditto formetacls). Rationale: this can be required when a method needs to take, or transparently pass through, a keyword argument with one of these names. - The first argument to
__new__of classes that subclasstypeshould probably be calledmetacls, notcls. And similarly — regular instance methods on metaclasses should takecls, and any classmethods should takemetacls. - Consider allowing
subcls/submetacls(depending on inheritance) for__init_subclass__, since that is actually significantly clearer.
What do you think?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the B902 rule entry point and review how it currently handles classmethod, new, and init_subclass. Compare the proposed _cls, metacls, subcls, and submetacls cases with the existing behavior; done requires an agreed scope and verified rule changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100