You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another false positive with the recent B024 is when implementing custom metaclass extended from ABCMeta - they shouldn't be classified as abstract base classes at all:
class MyMeta(abc.ABCMeta): # THIS GETS FALSE POSITIVE B024 BUT IS PERFECTLY LEGIT
def __new__(mcs, name, bases, namespace):
# whatever custom metaclass magic here
return super().__new__(mcs, name, bases, namespace)
class MyAbstract(metaclass=MyMeta):
@abstractmethod
def foobar(self):
pass
B024 MyMeta is an abstract base class, but it has no abstract methods. Remember to use @abstractmethod, @abstractclassmethod and/or @abstractproperty decorators.
class MyMeta(abc.ABCMeta):
-> MyMeta is actually not an abstract base class (instead, it is a custom metaclass for creating abstract base classes) so this is false positive.
The text was updated successfully, but these errors were encountered:
Ah, we should only warn on ABCMeta when it's a keyword argument (with metaclass=), and for ABC when that's a positional argument. is_abc_class() is currently a bit too broad.
jakkdl
added a commit
to jakkdl/flake8-bugbear
that referenced
this issue
Sep 29, 2022
Another false positive with the recent B024 is when implementing custom metaclass extended from ABCMeta - they shouldn't be classified as abstract base classes at all:
->
MyMeta
is actually not an abstract base class (instead, it is a custom metaclass for creating abstract base classes) so this is false positive.The text was updated successfully, but these errors were encountered: