-
-
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
Implement proper support for nested complex env values #22
Conversation
Co-authored-by: Hasan Ramezani <[email protected]>
Codecov ReportPatch coverage:
📣 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
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. |
There was a problem hiding this 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)): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
thanks. |
Port pydantic/pydantic#4216