-
Notifications
You must be signed in to change notification settings - Fork 82
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
injector.Injector.create_object
on pydantic-settings BaseSettings
does not without factory function in Injector
#253
Comments
Thanks for reporting! Could you please post a stack trace or similar to aid anyone that would be willing to try to solve this? |
As displayed through pytest, while running the attached project with the reproducable error: Python 3.8
raised by:
Python 3.9
raised by
|
Hey @Guibod, sorry for your bad experience here. From a quick look it looks like a pydantic-settings problem – using Python 3.10+ constructs on older Python versions – and I'm not sure trying to find a way to hack around that is the right thing to do. |
At least the issue is documented, as well as a work-around. So you don’t have to be sorry about it. It was discarded by You can close or leave the ticket open. It’s your choice. |
As stated in this closed bug at
pydantic-settings
, i cannot achieve an initialization throughinjector
on python 3.8 and 3.9 (works ok on 3.10+) without a factory method.The issue was turned down by the
pydantic-settings
team.The error message
Why ?
Pydantic BaseSettings base class uses PEP-604 (
str | None
) annotation instead of PEP-484 (Union
,Optional
).It seems that Pydantic BaseSettings class don’t like to be initialized through
cls.__new__(cls)
.This works
This does not
Reproduced issue
https://github.com/Guibod/pydantic-settings-bug-298
The text was updated successfully, but these errors were encountered: