Open alexey-pelykh opened 1 year ago
Is mcs
a well known for a meta class? If so, I'd take a PR allowing this if the class is Abstract of some description.
@cooperlees mcs
is already supported since 19.3.0, the issue is about determining what's a meta class here https://github.com/PyCQA/flake8-bugbear/blob/d1a8f2bcc09dd84e8dc743b05876cbd058ee3f20/bugbear.py#L990
abc.ABCMeta
is also a meta class yet it won't be detected as one if there's another class like in the example extending it.
seems pretty straightforward to extend the check to also check for inheritance from [abc.]ABCMeta
It would seem that hardcoding all well-known meta classes list is going to be a never-ending story. Yet it's not my call to suggest how to tackle this issue
that's unfortunately the way that AST-based static analysis checkers kind of have to do it. The "proper" way of doing it would be to hook into a type checker, but that's currently only possible if switching to LibCST and users run Pyre as their typechecker.
Note that I added a list of well-known metaclasses in #415. It currently only contains the ones from the standard library, but that could of course be extended.
@henzef I wonder if that could be extended to a configurable custom list from settings or something 🤔
It could definitely be done, adding something similar to --classmethod-decorators
, if there's sufficient interest.
causes B902 false-positive