Skip to content

Unsupported left operand type for | ("auto") #3434

Description

@lambdalisue

Using enum.auto in enum.Flag which has introduced from Python 3.6 cause the following exception

flag.py|8 error| Unsupported left operand type for | ("auto")

with the following code

fromenumimportFlag, autoclassColor(Flag):
RED=auto()
BLUE=auto()
GREEN=auto()
WHITE=RED|BLUE|GREEN " <--Thisline.
if__name__=='__main__':
assertnotbool(Color.RED&Color.BLUE)
assertnotbool(Color.RED&Color.GREEN)
assertbool(Color.RED&Color.WHITE)

The | operand is supported in enum.Flag so it seems the definition of auto() should be modified for Python 3.6 and over

Ref:
https://docs.python.org/3.6/library/enum.html#flag

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions