diff --git a/pyproject.toml b/pyproject.toml index 0f04bd1..70fe6bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lib-shared-models" -version = "0.1.0" +version = "0.1.1" description = "Shared model(s) to validate against" requires-python = ">=3.9" dependencies = [] diff --git a/src/shared_models/message.py b/src/shared_models/message.py index ac613c4..c4ed114 100644 --- a/src/shared_models/message.py +++ b/src/shared_models/message.py @@ -112,7 +112,9 @@ class Message: raise MessageValidationError(issues) return cls(title, body, link, category, timestamp) - def to_dict(self) -> dict[str, Any]: + def to_dict(self, *, exclude_none: bool = False) -> dict[str, Any]: d = asdict(self) d["category"] = self.category.value + if exclude_none: + d = {k: v for k, v in d.items() if v is not None} return d \ No newline at end of file