Skip to content

Fix for CloudPickle Dropping Type Hints #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
- Support pickling of classmethod and staticmethod objects in python2.
arguments. ([issue #262](https://github.com/cloudpipe/cloudpickle/pull/262))

- Add support to pickle type annotations for Python 3.5 and 3.6 (pickling type
annotations was already supported for Python 3.7, Python 3.4 might also work
but is no longer officially supported by cloudpickle)
([issue #276](https://github.com/cloudpipe/cloudpickle/pull/276))

1.1.1
=====

Expand Down Expand Up @@ -77,7 +82,7 @@
- Stop using the deprecated `imp` module under Python 3.
([issue #207](https://github.com/cloudpipe/cloudpickle/issues/207))

- Fixed pickling issue with singleton types `NoneType`, `type(...)` and
- Fixed pickling issue with singleton types `NoneType`, `type(...)` and
`type(NotImplemented)` ([issue #209](https://github.com/cloudpipe/cloudpickle/issues/209))


Expand Down
2 changes: 1 addition & 1 deletion cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def save_function_tuple(self, func):
'name': func.__name__,
'doc': func.__doc__,
}
if hasattr(func, '__annotations__') and sys.version_info >= (3, 7):
if hasattr(func, '__annotations__') and sys.version_info >= (3, 4):
state['annotations'] = func.__annotations__
if hasattr(func, '__qualname__'):
state['qualname'] = func.__qualname__
Expand Down
4 changes: 2 additions & 2 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,9 +1588,9 @@ def g():

self.assertEqual(f2.__doc__, f.__doc__)

@unittest.skipIf(sys.version_info < (3, 7),
@unittest.skipIf(sys.version_info < (3, 4),
"""This syntax won't work on py2 and pickling annotations
isn't supported for py36 and below.""")
isn't supported for py34 and below.""")
def test_wraps_preserves_function_annotations(self):
from functools import wraps

Expand Down