flags: support accessing flag value instances on the class

Fixes #4023
This commit is contained in:
Io Mintz 2020-04-20 14:59:58 -05:00 committed by GitHub
parent e473f3c775
commit a8baf0c9f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,11 +35,16 @@ class flag_value:
self.__doc__ = func.__doc__
def __get__(self, instance, owner):
if instance is None:
return self
return instance._has_flag(self.flag)
def __set__(self, instance, value):
instance._set_flag(self.flag, value)
def __repr__(self):
return '<flag_value flag={.flag!r}>'.format(self)
def fill_with_flags(*, inverted=False):
def decorator(cls):
cls.VALID_FLAGS = {