Skip to content

Commit

Permalink
improve: Allow unknown fields in dataclasses
Browse files Browse the repository at this point in the history
Will not be included in output of `to_dict`, this will be fixed later. This is merely just to not throw an error when extra fields are provided
  • Loading branch information
MarkLark86 committed Nov 11, 2024
1 parent 773ddd3 commit de1cfbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions superdesk/core/resources/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def dataclass(*args, **kwargs):
"""Superdesk Dataclass, that enables same config as `ResourceModel` such as assignment validation"""

config = deepcopy(model_config)
# By default, we allow extra values in dataclasses, but they won't be included in to_dict output.
# TODO-ASYNC: Fix to_dict to include extra fields not defined in the dataclass
config["extra"] = "allow"
config.update(kwargs.pop("config", {}))

return pydataclass(*args, **kwargs, config=model_config)
Expand Down

0 comments on commit de1cfbc

Please sign in to comment.