Skip to content

Commit

Permalink
B902: Add exceptions for standard library metaclasses
Browse files Browse the repository at this point in the history
I faced a false positive when deriving my metaclass from ABCMeta, which should be fixed with this commit. I also added EnumMeta to this list, because it was the only other public metaclass in the standard library.
  • Loading branch information
henzef committed Nov 7, 2023
1 parent 907e0dd commit 9775398
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bugbear.py
Expand Up @@ -1028,7 +1028,7 @@ def is_classmethod(decorators: Set[str]) -> bool:
return

bases = {b.id for b in cls.bases if isinstance(b, ast.Name)}
if "type" in bases:
if any(basetype in bases for basetype in ("type", "ABCMeta", "EnumMeta")):
if is_classmethod(decorators):
expected_first_args = B902.metacls
kind = "metaclass class"
Expand Down

0 comments on commit 9775398

Please sign in to comment.