You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error message is correct. Color(0, 1) calls for creating a new enum subclass with value0 and names1. See enum.py line700
def__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
""" Either returns an existing member, or creates a new enum class. This method is used both when an enum class is given a value to match to an enumeration member (i.e. Color(3)) and for the functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')). When used for the functional API: `value` will be the name of the new class. `names` should be either a string of white-space/comma delimited names (values will start at `start`), or an iterator/mapping of name, value pairs. ... """ifnamesisNone: # simple value lookupreturncls.__new__(cls, value)
# otherwise, functional API: we're creating a new Enum typereturncls._create_(value, names, ...)
According to the doc, subclassing an enumeration is allowed only if the enumeration does not define any members. So in enum.py line930 it raised the error.
Using the example from the docs:
Actual output (py 3.11):
Expected output- not 100% sure but, something along the lines of:
TypeError
saying "... takes 1 positional argument but 2 were given" likeColor()
does, orValueError
saying "... is not a valid Color" likeColor(0)
doesThe current metaclass error message is a bit confusing.
The text was updated successfully, but these errors were encountered: