-
Notifications
You must be signed in to change notification settings - Fork 829
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
881: Corrected enum metaclass to fix pickle.dumps() #1495
Conversation
this is fix for issue #881. |
55f3d1f
to
f5b5a14
Compare
wow, seems fix doesn't work well for python less than 3.11. Will check with lower versions. |
update: this was not related to tox in any way, but that was case with colliding enum class names defined in different modules (in different tests). |
Thank you for your submission of the PR and for conducting the investigation! I find it reasonable to enforce the uniqueness of Enum Names, as type names within a GQL schema are inherently unique. I would appreciate it if you could clarify whether this restriction solely applies to graphene Enums or if both Graphene Enums and normal Enums can have the same name. I am also interested in exploring other methods of enhancing pickle support. Would a solution like the following be effective in addressing the issue? class EnumMeta:
...
def __reduce__(self):
return (self.__name__, tuple(self.__bases__), dict(self.__members__)) |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1495 +/- ##
=======================================
Coverage 96.00% 96.01%
=======================================
Files 51 51
Lines 1753 1755 +2
=======================================
+ Hits 1683 1685 +2
Misses 70 70
☔ View full report in Codecov by Sentry. |
Well, first of all, enforcing uniquness (of graphene enums only) is simple to implement, one more check can be added in Also not sure should we put hard restriction in creation non-unique graphene Enums or not, because the only side effect from this is that pickling wouldn't work, which is not so wide-used feature, and all other functionality works just fine. On the other hand, if we don't, user potentially may receive weird errors while pickling. Limitation of unique Enum classes goes only for graphene enums and doesn't affect native python Enums in any way. About your last question regarding better enum support and use some other methods like So to sum this up, I will commit another changes which revert code back to commit 1, but will rename class to get it unique to make tests pass. |
@erikwrede , should be something else get changed here or that could be merged..? |
Hey, thanks for the patience. |
Well, I probably am not completely sure about your considerations about possible conflicts. At least in specific example you gave that shouldn't be any conflict. |
No description provided.