-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
[Enum] add __deepcopy__ method to Enum #106602
Comments
Hi @ethanfurman, I thought of implementing this. did you mean we should be able to make a deep copy of the whole enum like adding if yes, then we need to make changes in copy module because Enums are getting created using a custom metaclass Where did the bug get reported? Do you know if I can see the StackOverflow link? if it's about copying a member (adding deepcopy in Enum) then I will explore more
currently, it is taking the same object for new_enum as well as self |
Yes, those should both be
An enum class, such as
This issue is where the bug was reported. |
The current |
Ohh, I thought, this one also got reported on StackOverflow just like a calendar module feature I once picked. I have added a PR |
(cherry picked from commit 357e9e9) Co-authored-by: Prince Roshan <[email protected]>
(cherry picked from commit 357e9e9) Co-authored-by: Prince Roshan <[email protected]>
gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106666) (cherry picked from commit 357e9e9) Co-authored-by: Prince Roshan <[email protected]>
gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106666) (cherry picked from commit 357e9e9) Co-authored-by: Prince Roshan <[email protected]>
Thanks, @Agent-Hellboy, for the help! |
Thanks @ethanfurman, looking forward to contributions like these. |
betterproto.Enum is missing __copy__ and __deepcopy__ implementations, which were recently added to enum.Enum, see python/cpython#106602 This fixes the bug where betterproto messages with Enums nested within cannot be copied via copy.deepcopy.
* Add betterproto.Enum __copy__ and __deepcopy__ implementations betterproto.Enum is missing __copy__ and __deepcopy__ implementations, which were recently added to enum.Enum, see python/cpython#106602 This fixes the bug where betterproto messages with Enums nested within cannot be copied via copy.deepcopy. * Type hint on Enum.__copy__ Co-authored-by: James Hilton-Balfe <[email protected]> * Type hint on Enum.__deepcopy__ Co-authored-by: James Hilton-Balfe <[email protected]> --------- Co-authored-by: James Hilton-Balfe <[email protected]>
* Add betterproto.Enum __copy__ and __deepcopy__ implementations betterproto.Enum is missing __copy__ and __deepcopy__ implementations, which were recently added to enum.Enum, see python/cpython#106602 This fixes the bug where betterproto messages with Enums nested within cannot be copied via copy.deepcopy. * Type hint on Enum.__copy__ Co-authored-by: James Hilton-Balfe <[email protected]> * Type hint on Enum.__deepcopy__ Co-authored-by: James Hilton-Balfe <[email protected]> --------- Co-authored-by: James Hilton-Balfe <[email protected]>
Linked PRs
The text was updated successfully, but these errors were encountered: