Skip to content

Optional parameters can be omitted from payload.#7

Merged
dahlia merged 3 commits intonirum-lang:masterfrom
kanghyojun:optional-omit
Jan 8, 2018
Merged

Optional parameters can be omitted from payload.#7
dahlia merged 3 commits intonirum-lang:masterfrom
kanghyojun:optional-omit

Conversation

@kanghyojun
Copy link
Copy Markdown
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
Copy Markdown
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

def is_optional_type(type_):
return is_union_type(type_) and \
any(isinstance(None, ut) for ut in get_union_types(type_))
Copy link
Copy Markdown
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