from abc import ABC
class Foo(ABC):
BAR = 1
def method(self):
bar()
Because of the BAR = 1 declaration, B024 is considering Foo an ABC, but it isn't.
Expected:
$ flake8 --isolated --select B024 abc.py
abc.py:4:1: B024 Foo is an abstract base class, but none of the methods it defines are abstract. This is not necessarily an error, but you might have forgotten to add the @abstractmethod decorator, potentially in conjunction with @classmethod, @property and/or @staticmethod.
$
But got:
$ flake8 --isolated --select B024 abc.py
$
Info:
$ flake8 --version
7.0.0 (flake8-bugbear: 24.4.26, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0) CPython 3.12.2 on Darwin
Because of the
BAR = 1
declaration, B024 is consideringFoo
an ABC, but it isn't.Expected:
But got:
Info:
This looks related to the fix for https://github.com/PyCQA/flake8-bugbear/issues/293.
If I comment out this code, it works as expected:
https://github.com/PyCQA/flake8-bugbear/blob/d1aec4cbef7c4a49147c428b7e4a97e497b5d163/bugbear.py#L925-L929
By the way, this same issue was reported to ruff in https://github.com/astral-sh/ruff/issues/11208 and they got a fix. Maybe here a similar patch would work?