A line like SERIALIZABLE = Union[ser_factory.get_serialazables()] and later using some_parameter: SERIALIZABLE does not work:
A static type checker (like mypy) does not execute the code and so does not know, which objects are serializable.
Do I understand it correctly, that the PyMoDAQ objects subclass SerializableBase?
In this case, we can define SERIALIZABLE = Union[BUILTIN_SERIALIZABLE, SerializableBase], where we list all builtins, which are manually added.
That makes all classes, which implement the functions defined in SerializableBase automatically fit for serialization, even for mypy.
A line like
SERIALIZABLE = Union[ser_factory.get_serialazables()]
and later usingsome_parameter: SERIALIZABLE
does not work: A static type checker (like mypy) does not execute the code and so does not know, which objects are serializable.Do I understand it correctly, that the PyMoDAQ objects subclass
SerializableBase
? In this case, we can defineSERIALIZABLE = Union[BUILTIN_SERIALIZABLE, SerializableBase]
, where we list all builtins, which are manually added.That makes all classes, which implement the functions defined in
SerializableBase
automatically fit for serialization, even for mypy.