Skip to content

Implement proper support for nested complex env values#22

Merged
samuelcolvin merged 2 commits into
pydantic:mainfrom
hramezani:nested_complex_env
Apr 27, 2023
Merged

Implement proper support for nested complex env values#22
samuelcolvin merged 2 commits into
pydantic:mainfrom
hramezani:nested_complex_env

Conversation

@hramezani

Copy link
Copy Markdown
Collaborator

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

codecov-commenter commented Apr 25, 2023

Copy link
Copy Markdown

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.

@hramezani
hramezani requested a review from samuelcolvin April 25, 2023 21:42

@samuelcolvin samuelcolvin left a comment

Copy link
Copy Markdown
Member

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.


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

Copy link
Copy Markdown
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
Copy Markdown
Collaborator 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
Copy Markdown
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
Copy Markdown
Collaborator 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

Copy link
Copy Markdown
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.

3 participants