IMO it's a feature, not a bug :-)
import enum class Foo(enum.Enum):
... A = 1 ... B = 1.0 ...
"However, two enum members are allowed to have the same value. Given two members A and B with the same value (and A defined first), B is an alias to A. By-value lookup of the value of A and B will return A. By-name lookup of B will also return A."
You can use @unique to detect such corner case:
... class Foo2(enum.Enum): ... A = 1 ... B = 1.0 ... ValueError: duplicate values found in <enum 'Foo2'>: B -> A
On Mon, Dec 28, 2020 at 1:25 AM Paul Bryan via Python-Dev email@example.com wrote:
Should this be considered a bug in the Enum implementation?
... A = True
... B = 1
... C = 0
... D = False
Seems to me like it should store and compare both type and value.
Paul _______________________________________________ Python-Dev mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://firstname.lastname@example.org/message/5IJPHFRL... Code of Conduct: http://python.org/psf/codeofconduct/