Skip to content

Optional[datetime] field with value null/None gets isoparse'd #456

Closed
@cfal

Description

@cfal

I have a field in my generated model like this:

timestamp: Union[Unset, datetime.datetime] = UNSET

My API returns {"timestamp": null}, which then gets deserialized as None, and ends up in the else clause of this generated code:

        if isinstance(_timestamp, Unset):
            timestamp = UNSET
        else:
            timestamp = isoparse(_timestamp)

.. when then ends up raising in dateutil's isoparser.py.

I'm using 0.10.1 and saw #381 and #420 - wondering if datetime.datetime wasn't fixed with that issue or if I'm doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions