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

Implement proper support for nested complex env values #22

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

hramezani
Copy link
Member

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.29 🎉

Comparison is base (ed64cfe) 95.61% compared to head (2b184ef) 95.91%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   95.61%   95.91%   +0.29%     
==========================================
  Files           5        5              
  Lines         251      269      +18     
  Branches       60       66       +6     
==========================================
+ Hits          240      258      +18     
  Misses         10       10              
  Partials        1        1              
Impacted Files Coverage Δ
pydantic_settings/sources.py 95.98% <100.00%> (+0.35%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

otherwise I think looks good, but I'm a bit unclear how this works, will be easier to review when next_field has a docstring.

@@ -288,6 +288,16 @@ def _field_is_complex(self, field: FieldInfo) -> Tuple[bool, bool]:

return True, allow_parse_failure

@staticmethod
def next_field(field: Optional[FieldInfo], key: str) -> Optional[FieldInfo]:
if not field or origin_is_union(get_origin(field.annotation)):
Copy link
Member

Choose a reason for hiding this comment

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

can you add a docstring?

Copy link
Member Author

Choose a reason for hiding this comment

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

added!

# check if env_val maps to a complex field and if so, parse the env_val
if target_field and env_val:
is_complex, allow_json_failure = self._field_is_complex(target_field)
if is_complex:
Copy link
Member

Choose a reason for hiding this comment

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

do we have a way to disable json parsing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried to disable it here but it doesn't work
I haven't looked deeply on it but seems we need it here

@samuelcolvin samuelcolvin merged commit 607f1e8 into pydantic:main Apr 27, 2023
18 checks passed
@samuelcolvin
Copy link
Member

thanks.

@hramezani hramezani deleted the nested_complex_env branch April 27, 2023 08:04
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.

None yet

3 participants