Skip to content

Commit

Permalink
fix: provide the required_field utility
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Sep 11, 2021
1 parent 7bff619 commit f5cbf9c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions beet/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"SENTINEL_OBJ",
"dump_json",
"extra_field",
"required_field",
"intersperse",
"normalize_string",
]
Expand Down Expand Up @@ -40,6 +41,14 @@ def extra_field(**kwargs: Any) -> Any:
return field(repr=False, hash=False, compare=False, **kwargs)


def required_field(**kwargs: Any) -> Any:
return field(**kwargs, default_factory=_raise_required_field)


def _raise_required_field():
raise ValueError("Field required.")


def intersperse(iterable: Iterable[T], delimitter: T) -> Iterator[T]:
it = iter(iterable)
yield next(it)
Expand Down

0 comments on commit f5cbf9c

Please sign in to comment.