[New-bugs-announce] [issue42385] Should enum.auto's behavior be adjusted for StrEnum to return the enum name?

Antony Lee report at bugs.python.org
Tue Nov 17 04:01:11 EST 2020


New submission from Antony Lee <anntzer.lee at gmail.com>:

Currently, enum.auto doesn't work with the new (Py3.10) StrEnum: `class E(enum.StrEnum): a = enum.auto()` results in `TypeError: 1 is not a string`.

I would guess that the most reasonable behavior for auto() in a StrEnum would be to return the name itself, as implemented in the AutoName example at https://docs.python.org/3.10/library/enum.html#using-automatic-values.  I believe that this may just be a matter of copying the corresponding `_generate_next_value_` implementation into the definition of StrEnum?

----------
components: Library (Lib)
messages: 381220
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Should enum.auto's behavior be adjusted for StrEnum to return the enum name?
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42385>
_______________________________________


More information about the New-bugs-announce mailing list