Skip to content

Commit 9775398

Browse files
committed
B902: Add exceptions for standard library metaclasses
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.
1 parent 907e0dd commit 9775398

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bugbear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ def is_classmethod(decorators: Set[str]) -> bool:
10281028
return
10291029

10301030
bases = {b.id for b in cls.bases if isinstance(b, ast.Name)}
1031-
if "type" in bases:
1031+
if any(basetype in bases for basetype in ("type", "ABCMeta", "EnumMeta")):
10321032
if is_classmethod(decorators):
10331033
expected_first_args = B902.metacls
10341034
kind = "metaclass class"

0 commit comments

Comments
 (0)