marsh.MISSINGΒΆ
This value is treated as the unset value by marsh
(not to be confused with None which may be a valid
value).
This can be useful when a default value is required by python even though the programmer wants the value to be required (missing).
import dataclasses
import marsh
@dataclasses.dataclass
class Config:
a: int = 3
@dataclasses.dataclass
class ExpandedConfig(Config):
b: str
The code above will fail to run, throwing
TypeError: non-default argument 'b' follows default argument
Instead we can use marsh.MISSING
...
@dataclasses.dataclass
class ExpandedConfig(Config):
b: str = marsh.MISSING
Trying to unmarshal this code we get the correct behavior
...
# fails with marsh.errors.MissingValueError
marsh.unmarshal(ExpandedConfig, {'a': 2})
Note
Using marsh.MISSING as input when unmarshaling
is sometimes allowed. For example, None accepts
marsh.MISSING. Mappings and sequences
will also default to an empty instance when the input
is marsh.MISSING.
The value of marsh.MISSING is the same as
omegaconf.MISSING, represented by the string
'???'.