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 prettyrepr of {IntEnum,Flag,IntFlag} instances is less than optimal.
What I Did
from enum import Enum, IntEnum, Flag, IntFlag
from prettyprinter import cpprint
for base in [Enum, IntEnum, Flag, IntFlag]:
class A(base):
a = 1; b = 2
print(base)
cpprint(A.a)
print(A.a)
if issubclass(base, Flag):
cpprint(A.a | A.b)
print(A.a | A.b)
print()
yields
<enum 'Enum'>
A.a # ok
A.a # (reference)
<enum 'IntEnum'>
A(<A.a: 1>) # non eval'able; should either be "A.a" (better) or "1" (worse)
A.a # (reference)
<enum 'Flag'>
A.a # ok
A.a # (reference)
A.None # wrong
A.b|a # (reference)
<enum 'IntFlag'>
A(<A.a: 1>) # same issue as with IntEnum
A.a # (reference)
A(<A.b|a: 3>) # non eval'able, but I think the non-evalable form "A.b|a" is clearly best
A.b|a # (reference)
The text was updated successfully, but these errors were encountered:
Description
The prettyrepr of {IntEnum,Flag,IntFlag} instances is less than optimal.
What I Did
yields
The text was updated successfully, but these errors were encountered: