Cloud pickle 0.5.5 now supports pickling of type annotations, but some of them cannot be pickled and loaded. Especially generic types that are based on base class Generic, like Sequence, Tuple, List, ...
Here is the issue:
importtypingimportcloudpicklecloudpickle.loads(cloudpickle.dumps(typing.Sequence[int]))
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Users/marcbeillevaire/anaconda/envs/test/lib/python3.6/typing.py", line948, in__new__raiseTypeError("Cannot inherit from plain Generic")
TypeError: CannotinheritfromplainGenericNote that this works fine:
importtypingimportcloudpicklecloudpickle.loads(cloudpickle.dumps(typing.Sequence)) # Sequence, not Sequence[int]
It looks like the arguments of __getitem__ get lost, and only the generic class is pickled -- here: Sequence, and not Sequence[int].
This leads to loading a class that inherits from typing.Generic, not typing.Generic[int] which raises the error (see typing.py line 948 where the error above is raised).
Cloud pickle 0.5.5 now supports pickling of type annotations, but some of them cannot be pickled and loaded. Especially generic types that are based on base class
Generic, like Sequence, Tuple, List, ...Here is the issue:
Note that this works fine:
It looks like the arguments of
__getitem__get lost, and only the generic class is pickled -- here: Sequence, and not Sequence[int].This leads to loading a class that inherits from
typing.Generic, nottyping.Generic[int]which raises the error (see typing.py line 948 where the error above is raised).