-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#100 Propagate meta dict to Nested dataclasses #106
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,7 @@ def class_schema( | |
attributes[field.name] = field_for_schema( | ||
hints.get(field.name, field.type), | ||
_get_field_default(field), | ||
field.metadata, | ||
{**meta, **field.metadata}, | ||
) | ||
|
||
cls_schema = type( | ||
|
@@ -289,7 +289,8 @@ def field_for_schema( | |
|
||
if field is None: | ||
nested = forward_reference or class_schema(typ) | ||
field = marshmallow.fields.Nested(nested) | ||
params = {k: v for k, v in metadata.items() if type(k) is str} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we are filtering for string keys, we don't have to worry about the Sentinel key breaking any typing expectations downstream. |
||
field = marshmallow.fields.Nested(nested, **params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the Nested class accepts |
||
|
||
field.metadata.update(metadata) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're using
field.metadata
second here, the parent Schema'smeta
dict will not overwrite a Nested field's potential metadata params.