Added backwards compatible feature that excludes entries with None
This commit is contained in:
1 parent
6e2442b41e
commit
1e36de5a9a
2 files changed
+4
-2
No files matched your search
+1
-1
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user