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

Allow nested env var source to override nested init source. #204

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

kschwab
Copy link
Contributor

@kschwab kschwab commented Jan 2, 2024

Resolves #203

Allows for nested EnvSettingsSource to override nested InitSettingsSource.

Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4f24fad) 97.47% compared to head (5519fd6) 97.47%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #204   +/-   ##
=======================================
  Coverage   97.47%   97.47%           
=======================================
  Files           5        5           
  Lines         317      317           
  Branches       66       66           
=======================================
  Hits          309      309           
  Misses          6        6           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -121,7 +121,7 @@ def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str,
return None, '', False

def __call__(self) -> dict[str, Any]:
return self.init_kwargs
return TypeAdapter(dict[str, Any]).dump_python(self.init_kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's failing on python 3.8

Suggested change
return TypeAdapter(dict[str, Any]).dump_python(self.init_kwargs)
return TypeAdapter(Dict[str, Any]).dump_python(self.init_kwargs)

@hramezani
Copy link
Member

Thanks @kschwab for this patch. You need to add some tests

@hramezani
Copy link
Member

Thanks @kschwab

@hramezani hramezani merged commit 2784a70 into pydantic:main Jan 5, 2024
20 checks passed
@kschwab kschwab mentioned this pull request Jan 31, 2024
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 this pull request may close these issues.

How to Override Deeply Nested Settings using Environment Variables?
2 participants