Optional parameters
from hanna import Configurable, Integer
class Settings(Configurable):
# This is treated as "no default given", i.e. the parameter is
# non-optional and the framework will raise an exception if it
# is not specified.
rng_seed = Integer(default=None)
# This marks the parameter explictly as optional and as a result
# it can be omitted from the configuration source. In that case
# the default `default` will be used (which is `None`).
rng_seed = Integer(optional=True)
settings = Settings()
assert setting.rng_seed is None
settings = Settings({'rng_seed': 123})
assert settings.rng_seed == 123Last updated