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

List of Nullable values are not converted to None in the to_dict function #136

Open
Golyo88 opened this issue Sep 21, 2020 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Golyo88
Copy link

Golyo88 commented Sep 21, 2020

to_dict not handled correctly where the field is a List with Nullable values

@dataclass(frozen=True)
class Range(JsonSchemaMixin):
    range: List[Nullable[float]]
    not_range: Nullable[float]

r = Range.from_dict({'range': [1.0, 2.0, None, 3.0], 'not_range': None})
r.to_dict()
{'range': [1.0, 2.0, <dataclasses_jsonschema.type_defs._NULL_TYPE object at 0x10c002e50>, 3.0], 'not_range': None}

As you can see Nullable field's value will convert to None in the to_dict() function, but the Nullable items of a List is not

@s-knibbs s-knibbs added the bug Something isn't working label Jan 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants