cloudpipe / cloudpipe/cloudpickle

cloudpickle cannot pickle `typing.ContextManager`

Open
#399 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
1

Description

Example:
```python
Factory = ContextManager[int]
cloudpickle.dumps(factory)
```

Produces on cloudpickle 1.6.0 and Python 3.7.9:
```
Traceback (most recent call last):
File "", line 1, in
File "/home/adam/dev/evaluating-rewards/venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py", line 73, in dumps
cp.dump(obj)
File "/home/adam/dev/evaluating-rewards/venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py", line 563, in dump
return Pickler.dump(self, obj)
File "/usr/lib/python3.7/typing.py", line 732, in __reduce__
origin = globals()[self._name]
KeyError: 'AbstractContextManager'
```

This issue also occurs when functions involve type annotations using `ContextManager` (a more common use case) where the annotations are implicitly pickled.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.