Skip to content

Weird error when using enum(val1, val2) #107878

Closed as not planned
Closed as not planned
@wimglenn

Description

@wimglenn

Using the example from the docs:

class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

Actual output (py 3.11):

>>> Color(0, 1)
TypeError: <enum 0> cannot extend <enum 'Color'>

Expected output- not 100% sure but, something along the lines of:

  • TypeError saying "... takes 1 positional argument but 2 were given" like Color() does, or
  • ValueError saying "... is not a valid Color" like Color(0) does

The current metaclass error message is a bit confusing.

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions