On 5/27/21 8:24 PM, Ethan Furman wrote:
> So, like the enum.unique decorator that can be used when duplicate names
should be an error,
> I'm adding a new decorator to verify that a Flag has no missing aliased
values that can be
> used when the programmer thinks it's appropriate... but I have no idea what
to call it.
>
> Any nominations?
Thank you everyone for your ideas! Instead of adding another single-purpose decorator, I'm toying with the idea of
adding a general purpose decorator that accepts instructions. Something along the lines of:
class EnumChecks(StrEnum):
"""
various conditions to check an enumeration for
"""
UNIQUE = "one name per value"
CONTINUOUS = "no skipped values"
DECOMPOSABLE_ALIASES = "flag aliases must have all bits named"
def verify(enumeration, *checks):
if UNIQUE in checks:
# ensure no duplicates
if CONTINUOUS in checks:
# ensure no missing values
if DECOMPOSABLE_ALIASES in checks:
# ensure all multi-flag aliases are composed of named flags
Thoughts?
--
~Ethan~
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DVFOYTEPFNUDXWIYS763XGTCWJ6GFL5U/
Code of Conduct: http://python.org/psf/codeofconduct/