Title: Should's behavior be adjusted for StrEnum to return the enum name?
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: ethan.furman Nosy List: Antony.Lee, barry, eli.bendersky, ethan.furman
Priority: normal Keywords:

Created on 2020-11-17 09:01 by Antony.Lee, last changed 2020-11-17 16:11 by ethan.furman.

Messages (2)
msg381220 - (view) Author: Antony Lee (Antony.Lee) * Date: 2020-11-17 09:01
Currently, doesn't work with the new (Py3.10) StrEnum: `class E(enum.StrEnum): a =` 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  I believe that this may just be a matter of copying the corresponding `_generate_next_value_` implementation into the definition of StrEnum?
msg381254 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2020-11-17 16:11
A good idea.

Since the Python opinion of enum members is that they be upper-cased, and every magic string constant I have seen is lower-case, `StrEnum._generate_next_value_` should lower case the name.  Users can substitute their own `_gnv_` for different behavior.
Date User Action Args
2020-11-17 16:11:54ethan.furmansetassignee: ethan.furman
type: behavior
messages: + msg381254
stage: needs patch
2020-11-17 10:00:47xtreaksetnosy: + barry, eli.bendersky, ethan.furman
2020-11-17 09:01:11Antony.Leecreate