This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Can't use frozen native dataclass #4763
Comments
In this case I think the response_model statement expect a pydantic object and not a dataclass. |
Note that If this is indeed a limitation, let's note this in FastAPI docs 🙏🏿 |
Why in your case, use a dataclass instead of a pydantic object? |
A couple of reasons, though perhaps neither is super important:
|
I wonder if pydantic/pydantic#3469 is related. |
Or maybe this: pydantic/pydantic#2555 |
Or this? pydantic/pydantic#2065 |
It looks like something would be more related to pydantic than actually fastapi from the data examples. |
Indeed it is. All I'm proposing is for FastAPI to document this limitation for the time being. |
OT: looks like my issue comments are breaking GHA:
|
It seems to be specific to something fastapi might do when it converts normal dataclasses to pydantic dataclasses? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
First Check
Commit to Help
Example Code
Description
Operating System
Linux
Operating System Details
Linux
FastAPI Version
0.75.1
Python Version
3.10, 3.11
Additional Context
pydantic 1.9.0
Workarounds:
frozen=True
, orfrom pyndatic.dataclasses impotr dataclass
-- the pydantic version works.It could be a bug in pydantic for all I know, or even a limitation, in which case
fastapi
docs need to be updated.The text was updated successfully, but these errors were encountered: