-
Notifications
You must be signed in to change notification settings - Fork 822
Cannot pickle graphene.Enum #881
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
Comments
(I think #879 also makes this stuff work) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
any fix for this...? |
Don't have idea why this gets closed and won't be fixed, from graphene.types.enum import EnumMeta as GrEnumMeta
import graphene.types.enum
class MyMeta(GrEnumMeta):
def __new__(cls, name_, bases, classdict, **options):
obj = super().__new__(cls, name_, bases, classdict, **options)
setattr(graphene.types.enum, name_, obj.__enum__)
return obj
class MyEnum(GrEnum, metaclass=MyMeta):
A = 'a'
B = 1
gr_enum = MyEnum.B
pickled = pickle.dumps(gr_enum)
restored = pickle.loads(pickled)
assert type(gr_enum) is type(restored)
assert gr_enum == restored |
@senseysensor nice fix, if you send in a PR including tests I can review & test 🙂 |
Sorry, unfortunately that solution above appeared to have some limitations. In order |
Environment
Mac OS
$ sw_vers -productVersion 10.14 $ python -V Python 3.6.3 $ python -c 'import graphene; print(graphene.__version__)' 2.1.3
Reproduce
Expected
Pickle can perform
dumps
andloads
ongraphene.Enum
objectsThe text was updated successfully, but these errors were encountered: