Skip to content

Commit

Permalink
Fix for derived classes without annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Dec 13, 2019
1 parent 2f9b3af commit b31548e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mashumaro/serializer/base/metaprogramming.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def namespace(self):

@property
def annotations(self):
return self.namespace['__annotations__']
return self.namespace.get('__annotations__', {})

def __get_fields(self, recursive=True):
fields = {}
Expand Down
5 changes: 5 additions & 0 deletions tests/test_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,5 +670,10 @@ class B(A, DataClassDictMixin):
class C(B, DataClassDictMixin):
y: int = 4

@dataclass
class D(C):
pass

assert B.from_dict({'x': 0}) == B(x=0, y=1, z=3)
assert C.from_dict({'x': 0}) == C(x=0, y=4, z=3)
assert D.from_dict({'x': 0}) == D(x=0, y=4, z=3)

0 comments on commit b31548e

Please sign in to comment.