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
Using
enum.autoinenum.Flagwhich has introduced from Python 3.6 cause the following exceptionwith the following code
The
|operand is supported inenum.Flagso it seems the definition ofauto()should be modified for Python 3.6 and overRef:
https://docs.python.org/3.6/library/enum.html#flag