Let's say I have a simple function:
import cloudpickle
import typing, inspect
def add(x: int=1,y: int=2 ) -> int:
return x+y
It runs as expected:
>>> add()
3
>>> print(typing.get_type_hints(add))
{'x': <class 'int'>, 'return': <class 'int'>, 'y': <class 'int'>}
Now if I pickle it, then unpickle the function, I lose the annotation for the typing.
>>> f = cloudpickle.loads(cloudpickle.dumps(add))
>>> print(typing.get_type_hints(f))
{}
>>> f()
3
So when a method is pickled/unpickled the typing is dropped. Is there anyway to include typing in the pickling process? It helps with introspection of a user's method when you send it someplace else.