-
Notifications
You must be signed in to change notification settings - Fork 75
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
Cannot convert with from_attributes
when using a rename convention
#630
Comments
Thanks for opening this. First, standardizing on terminology. Given your field Originally There are 3 kinds of things that may be converted into a struct/dataclass from by
A few options:
Thoughts? |
Hi Jim, thanks for taking the time to provide context. In my own use cases (mostly REST APIs), I try to have everything internal to my application use snake_case, whereas the public JSON schemas use camelCase. However, this linked issue comment outlines that this isn't always the case. As for solutions, having For what it is worth, Pydantic's |
This is fixed by #636. I ended up going for the inference option - in practice the inference is pretty efficient and only results in at most 1 unnecessary |
Description
Some example code using a
Struct
withrename="camel"
:Raises:
Is there a way around this? For this specific example, we can leverage unpacking the dataclass'
asdict()
result, but this isn't always straightforward with an ORM instance. I actually discovered this behaviour using a SQLAlchemy model.The text was updated successfully, but these errors were encountered: