Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pawamoy opened this issue Aug 13, 2020 · 2 comments
Closed

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

pawamoy opened this issue Aug 13, 2020 · 2 comments
Labels
✨ enhancement New feature or improvement
Milestone

Comments

@pawamoy
Copy link

pawamoy commented Aug 13, 2020

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
@pawamoy pawamoy added the 🐞bug Something isn't working label Aug 13, 2020
@dbanty
Copy link
Collaborator

dbanty commented Aug 13, 2020

Shouldn't be a problem, I don't think that OpenAPI strictly uses isoformat anyway, so we can replace that with a strptime.

@dbanty dbanty added ✨ enhancement New feature or improvement and removed 🐞bug Something isn't working labels Aug 18, 2020
@dbanty dbanty added this to the Python 3.6 Support milestone Aug 18, 2020
@dbanty dbanty modified the milestones: Python 3.6 Support, 0.6.0 Sep 6, 2020
dbanty added a commit that referenced this issue Sep 6, 2020
dbanty added a commit that referenced this issue Sep 7, 2020
@dbanty
Copy link
Collaborator

dbanty commented Sep 21, 2020

This should be complete with #137, so marking as closed.

@dbanty dbanty closed this as completed Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants