Skip to content

type object 'datetime.datetime' has no attribute 'fromisoformat' #154

Closed
@pawamoy

Description

@pawamoy

Describe the bug
The generated code uses fromisoformat to convert a datetime. Unfortunately, fromisoformat was introduced in Python 3.7 and therefore is not available on Python 3.6 (see #137).

To Reproduce
Generate a client from a spec containing a schema with a property such as:

LastModificationDate:
  type: string
  format: date-time

When using the client, you'll get the following error:

/path/to/client/models/schema.py in from_dict(d), line 47:
  last_modification_date = datetime.fromisoformat(cast(str, d.get("lastModificationDate")))
AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

Expected behavior
No exception. This is just something to adapt for Python 3.6 support 🙂

Desktop (please complete the following information):

  • OS: RedHat 7
  • Python Version: 3.6.8
  • openapi-python-client version 0.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions