Given the following enum:
class MyEnum(enum.Enum):
Field1 = "Field1"
Field2 = "Field2" # should be deprecated for `Field3`
Filed3 = "Field3"
I'd like to add a deprecation warning to a field such that when I call MyEnum.Field2
or MyEnum("Field2")
a <MyEnum.Field3: 'Field3'>
enum instance will be returned as well as a deprecation warning.
What is the proper way to do so? Is there a python language feature that can do this?