Skip to content
This repository was archived by the owner on Aug 19, 2023. It is now read-only.

Conversation

@amigold
Copy link

@amigold amigold commented Sep 26, 2020

If a type is nullable and we got None input, we should decode as None and not the _NULL_TYPE class.

Otherwise it causes strange behaviour

If a type is nullable and we got None input, we should decode as None and not the _NULL_TYPE class.

Otherwise it causes strange behaviour
@jsangilve
Copy link

I think this would break the from_dict. For example:

  @dataclass
  class PayloadWithNullable(InputModel):
      required: str
      opt_nullable: Nullable[Optional[str]] = None

# ...
assert PayloadWithNullable.from({'required': 'foo'}) == PayloadWithNullable(required='foo', opt_nullable=None)
assert PayloadWithNullable.from({'required': 'foo', 'opt_nullable': None}) == PayloadWithNullable(required='foo', opt_nullable=NULL)

@amigold
Copy link
Author

amigold commented Oct 15, 2020

Those asserts are both true @jsangilve ?
The second one should also be

assert PayloadWithNullable.from({'required': 'foo', 'opt_nullable': None}) == PayloadWithNullable(required='foo', opt_nullable= None)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants