Skip to content

Commit

Permalink
Issue #282
Browse files Browse the repository at this point in the history
  • Loading branch information
loyada committed Dec 12, 2023
1 parent f6f1ee0 commit 5ddfef4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
license="MIT",
long_description=long_description,
url="http://github.com/loyada/typedpy",
download_url="https://github.com/loyada/typedpy/archive/v2.27.3.tar.gz",
download_url="https://github.com/loyada/typedpy/archive/v2.27.4.tar.gz",
keywords=["testing", "type-safe", "strict", "schema", "validation"],
version="2.27.3",
version="2.27.4",
)

# coverage run --source=typedpy/ setup.py test
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fast_serialization_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ class Foo(Structure, FastSerializable):

def test_additional_serialization(no_defensive_copy_on_get):
class Foo(Structure, FastSerializable):
first_name: String
last_name: String
first_name: str
last_name: str
age_years: PositiveInt

def _additional_serialization(self) -> dict:
Expand Down
9 changes: 6 additions & 3 deletions typedpy/serialization/fast_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ def serializer(self):
if with_undefined
else res
)
additional = self._additional_serialization() if has_additional_properties else {}
return (
res = (
filtered_res
if serialize_none
else {k: v for (k, v) in filtered_res.items() if v is not None}
) | additional
)
if has_additional_properties:
res.update(self._additional_serialization())

return res

cls.serialize = serializer

Expand Down

0 comments on commit 5ddfef4

Please sign in to comment.