On 7/23/20 12:24 PM, firstname.lastname@example.org wrote:
I have run into a situations when an enum member becomes obsolete. However, I'd like to avoid removing the member from the enum to give time for users to catch up to a libraries core types.
This would be good.
I've seen Java has a @Deprecated annotation for their Enums. Python enum's can also set an _ignore_ attribute which will avoid instantiating a member in the list.
The purpose behind _ignore_ is to be able to use temporary variables without those variables becoming members.
I've implemented a similar approach to solve deprecating enum members.
You can check it out here: https://github.com/foxyblue/cpython/pull/1
Interesting. I prefer the approach in my Stackoverflow answer:
Yours is quite similar, but mine is more general-purpose and so easily allows for a useful message as well.