Skip to content

Optional parameters can be omitted from payload. #7

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

Merged
merged 3 commits into from
Jan 8, 2018

Conversation

kanghyojun
Copy link
Member

@kanghyojun kanghyojun commented Jan 8, 2018

@kanghyojun kanghyojun self-assigned this Jan 8, 2018
@kanghyojun kanghyojun requested a review from dahlia January 8, 2018 13:21
nirum_wsgi.py Outdated
def _get_argument_value(payload, key, type_):
# if is_union_type(type_) is true, type_ is optional type.
# https://github.com/spoqa/nirum-python/blob/maintenance-0.6/nirum/deserialize.py#L209
if key in payload or is_union_type(type_):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better have nirum._compat.is_optional_type() or such thing which tests whether it's a union type and one of its possible types is type(None).

nirum_wsgi.py Outdated
@@ -44,6 +45,22 @@
])


def is_optional_type(type_):
return is_union_type(type_) and \
any(isinstance(None, ut) for ut in get_union_types(type_))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not type(None) in get_union_types(type_)

@dahlia dahlia merged commit 08ab617 into nirum-lang:master Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants