Skip to content

Commit

Permalink
Release 0.27.2
Browse files Browse the repository at this point in the history
  • Loading branch information
avanov committed Jun 18, 2020
1 parent 7016613 commit 2fc7957
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
=========

0.27.2
===============

* Mapping nested values are serialized according to their custom type definition.


0.27.1
===============

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# The short X.Y version.
version = '0.27'
# The full version, including alpha/beta/rc tags.
release = '0.27.1'
release = '0.27.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def requirements(at_path: Path):
# ----------------------------

setup(name='typeit',
version='0.27.1',
version='0.27.2',
description='typeit brings typed data into your project',
long_description=README,
classifiers=[
Expand Down
22 changes: 22 additions & 0 deletions tests/std_types/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ class X(NamedTuple):
assert x.pmap_[Attr.x] == 'value'


def test_typed_mapping_values():
class Attr(Enum):
x = 'x'

class Val(NamedTuple):
val: str

class X(NamedTuple):
map: Mapping[Attr, Val]

mk_x, serialize_x = TypeConstructor ^ X

data = {
'map': {'x': {'val': 'value'}},
}

x = mk_x(data)

assert x.map[Attr.x] == Val(val='value')
assert serialize_x(x) == data


def test_sequence():
class X(NamedTuple):
xs: collections.abc.Sequence
Expand Down
5 changes: 4 additions & 1 deletion typeit/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def deserialize(self, node, cstruct):

def serialize(self, node, appstruct):
r = super().serialize(node, appstruct)
return r
if r in (Null, None):
return r

return {self.key_node.serialize(k): self.value_node.serialize(v) for k, v in r.items()}


class Path(primitives.Str):
Expand Down

0 comments on commit 2fc7957

Please sign in to comment.