I have the following code:
class Category(abc.ABC):
foo = {"bar"}
Despite inheriting from abc.ABC
, I can instantiate a Category
just fine:
>>> a = Category()
>>>
whereas I would expect it to raise an error like the following.
>>> class Foo(abc.ABC):
... @abc.abstractmethod
... def bar(self):
... return "baz"
...
>>> f = Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class Foo with abstract methods bar
>>>
It seems that this is because Category
has no abstract methods. How can I ensure that trying to instantiate Category
will raise an exception?