PyMoDAQ / pymodaq_data

Allows data management within the PyMoDAQ ecosystem and HDF5 compatibility
https://pymodaq.cnrs.fr
MIT License
0 stars 2 forks source link

Conflict between typing constang SERIALIZABLE and dynamic possibilities of serializer factory. #9

Closed BenediktBurger closed 2 days ago

BenediktBurger commented 6 days ago

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.

seb5g commented 2 days ago

I'm closing this as your pr solved it