Skip to content
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

ENH: Support pickling dynamic Enum subclasses. #105

Closed
wants to merge 1 commit into from

Conversation

ssanderson
Copy link

@ssanderson ssanderson commented Jul 2, 2017

#101

NOTE: I'm not totally convinced that we actually want to support dynamic Enums. See #101 (comment) for more discussion.

@codecov-io
Copy link

codecov-io commented Jul 2, 2017

Codecov Report

Merging #105 into master will increase coverage by 0.81%.
The diff coverage is 95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   81.34%   82.16%   +0.81%     
==========================================
  Files           2        2              
  Lines         563      583      +20     
  Branches      113      117       +4     
==========================================
+ Hits          458      479      +21     
  Misses         75       75              
+ Partials       30       29       -1
Impacted Files Coverage Δ
cloudpickle/cloudpickle.py 82.06% <95%> (+0.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d986894...f0374d2. Read the comment docs.


This is what gets called to save enum members.
"""
self.save_reduce(getattr, (type(obj), obj.name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only line that isn't covered by the test suite currently.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. It's easy enough to add coverage for this case if we decide we want this feature, though I'm not totally convinced it's a good idea because idiomatic usage of Enum involves lots of is comparisons, which will break silently if a user unpickles the same Enum multiple times.

@ssanderson
Copy link
Author

I'm gonna close this for now. I think this is providing too big a footgun for too small a benefit. If someone comes along and really wants support for enums defined in __main__, we can reconsider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants