From 9775398f630842a3a143f622be3bc45b9f2fb268 Mon Sep 17 00:00:00 2001 From: Fabian Henze <32638720+henzef@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:16:44 +0200 Subject: [PATCH] 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. --- bugbear.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bugbear.py b/bugbear.py index 5fbfa19..e296f55 100644 --- a/bugbear.py +++ b/bugbear.py @@ -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"