-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Description
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:
import typing
import cloudpickle
cloudpickle.loads(cloudpickle.dumps(typing.Sequence[int]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/marcbeillevaire/anaconda/envs/test/lib/python3.6/typing.py", line 948, in __new__
raise TypeError("Cannot inherit from plain Generic")
TypeError: Cannot inherit from plain GenericNote that this works fine:
import typing
import cloudpickle
cloudpickle.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).
Metadata
Metadata
Assignees
Labels
No labels