espnet3.contract.data.require_fields
Less than 1 minute
espnet3.contract.data.require_fields
espnet3.contract.data.require_fields(obj, attr: str) → None
Raise because obj declares no attr.
Every dataset must declare its item fields - as a class attribute, or set on self for one that depends on its own configuration; there is no undeclared fallback.
- Parameters:
- obj – The class to check, or an instance whose own attributes (set in its
__init__) declare a contract its class does not. - attr – The attribute name, such as
"fields".
- obj – The class to check, or an instance whose own attributes (set in its
- Returns: Nothing; it always raises
TypeError.
Examples
>>> class Undeclared:
... pass
>>> require_fields(Undeclared, "fields")
Traceback (most recent call last):
TypeError: Undeclared does not declare fields; declare `fields` ...