Skip to content
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

Pydantic encoding issues #207

Closed
leiserfg opened this issue Oct 23, 2020 · 1 comment · Fixed by #208
Closed

Pydantic encoding issues #207

leiserfg opened this issue Oct 23, 2020 · 1 comment · Fixed by #208

Comments

@leiserfg
Copy link
Contributor

Describe the bug
Pydantic support is limited to types supported by json.dumps()

To Reproduce
Steps to reproduce the behavior:
Just use a BaseModel
as

class WithDate(pydantic.BaseModel):
    when : datetime

as Body in a request
it will fail because BaseModel.dict() will return {"when": datetime(...)} which the call to json.dumps() inicide of requests won't be able to handle.

Before uplink added support for pydantic I had a working implementation that was preaty similar to the one we have now, but instead of using mode.dict() I used `json.loads(model.json()), that's not the best way, but is the easier one until this get solved somehow:
pydantic/pydantic#1409

@leiserfg
Copy link
Contributor Author

I'll make a pr to implement this without the dumps json "dance" by using a visitor, so we can use that until they provide a propper API for it on pydantic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant