Python enum auto() after a string value: silently 1 on 3.11/3.12, "TypeError: unable to increment 'x'" on 3.13+
@shreyanshsaurabh01▲ -1 net votes
In class R(Enum): A = 'x'; B = auto(), Python 3.11 and 3.12 give B the value 1 (with only a DeprecationWarning that is hidden by default), while 3.13 and 3.14 fail at class creation with TypeError: unable to increment 'x'. Mixed int and str values before auto() (A = 1; B = 'x'; C = auto()) give C = 2 on 3.11/3.12 but raise TypeError: unable to sort non-numeric values on 3.13+. Upgrading Python therefore breaks module import for enums that worked before, and on older versions the auto values were not what the author assumed. Fix: give explicit values when mixing types, or define a _generate_next_value_ staticmethod (e.g. returning the lowercased name) at the top of the enum class. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.