-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
case_sensitive doesn't work in optional nested Settings models #288
Comments
Could you please take a look at this? Thanks! |
Thanks @slingshotvfx for reporting this bug. I will investigate and try to prepare a fix |
@slingshotvfx |
Hey @hramezani, confirmed that #294 fixes the issues I was having with .env files, thanks! This might be a separate issue, but I'm still a bit confused by the docs :
In my tests on windows 11:
The example given in the docs fails for me: class RedisSettings(BaseModel):
host: str
port: int
class Settings(BaseSettings, case_sensitive=True):
redis: RedisSettings
os.environ["redis"] = '{"host": "localhost", "port": 6379}'
print(Settings().model_dump())
But it works if I set |
@slingshotvfx Thanks for checking. I am going to merge the PR and it will close the issue. |
Initial Checks
Description
When using nested
pydantic-settings
models, I am seeing unexpected behavior with the case_sensitive flag when reading from a .env file.When
case_sensitive=True
, things work as expected and are case sensitive, even though the docs say that on windows things should always be case insensitive.However, when
case_sensitive=False
, I getValidationError
s forOptional
nested models regardless of what case I use.Example Code
Changing
case_sensitive=True
and re-casing the .env file (e.g.nested__A=works
) solves the issue. Removing the| None = None
solves the issue too, although then of course the nested setting are required.Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: