Skip to content

Commit

Permalink
Exclude unknown fields from the config by default
Browse files Browse the repository at this point in the history
This is what most users will need, so we better make it the default.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
  • Loading branch information
llucax committed Dec 10, 2024
1 parent 0cc7e94 commit 4189066
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/frequenz/sdk/config/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def new_receiver( # noqa: DOC502
Additional arguments can be passed to [`marshmallow.Schema.load`][] using
the `marshmallow_load_kwargs` keyword arguments.
If unspecified, the `marshmallow_load_kwargs` will have the `unknown` key set to
[`marshmallow.EXCLUDE`][] (instead of the normal [`marshmallow.RAISE`][]
default).
### Skipping superfluous updates
If there is a burst of configuration updates, the receiver will only receive the
Expand Down Expand Up @@ -317,6 +321,9 @@ def _is_dataclass(config: DataclassT | None) -> TypeGuard[DataclassT]:
"""Return whether the configuration is a dataclass."""
return config is not None

if "unknown" not in marshmallow_load_kwargs:
marshmallow_load_kwargs["unknown"] = marshmallow.EXCLUDE

recv_name = f"{self}_receiver" if key is None else f"{self}_receiver_{key}"
receiver = self.config_channel.new_receiver(name=recv_name, limit=1)

Expand Down

0 comments on commit 4189066

Please sign in to comment.