Greetings! It’s my very first topic on this forum so I apologize in advance if this has already been answered somewhere else.
EDIT: forgot to mention:
- OS: Windows 11
- Python: 3.10.15
I’m developing a software which is divided into two separately shipped packages:
- a toolkit package;
- a core package.
This is because the toolkit gives the opportunity to other contributors to build plugins to attach to the core.
In the toolkit I have the following classes (I’m just leaving the class declaration since the content is not relevant - I think):
toolkit\log.py
from abc import ABC
class Loggable(ABC):
...
toolkit\handler.py
from toolkit.log import Loggable
from abc import ABCMeta
class Handler(Loggable, metaclass=ABCMeta):
...
The Loggable class provides a standard interface to provide log messages which are written in the core logger.
The Handler class is an example implementation of how to use the Loggable class to extend another abstract class.
While writing this topic I realize that Loggable doesn’t have to be abstract as well for my purposes but for now I’ll just leave it at that.
In the core package, I have an implementation of Handler:
core\handler.py
from toolkit.handler import Handler
class EngineHandler(Handler):
...
Now when running mypy on the core package, I get the following error:
Class cannot subclass "Handler" (has type "Any")
What exactly is going on here? Why is it complaining about this inheritance? Is it related to the content of the Handler or Loggable classes somehow?