In case we want the user to specify a value from a discrete set of possible choices we can do so in the following ways:
from hanna import Configurable, String
class Settings(Configurable):
log_level = String(choices=('info', 'warn', 'error'))
log_level.choices = ('info', 'warn', 'error') # Similar.
In case a value is specified that is not part of the declared possible choices a ValueError
will be raised:
# raises ValueError: "log_level" Illegal choice ('debug' not in ('info', 'warn', 'error'))
settings = Settings({'log_level': 'debug'})