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

Fix for JSON on optional nested types. #217

Merged
merged 7 commits into from
Jan 26, 2024

Conversation

kschwab
Copy link
Contributor

@kschwab kschwab commented Jan 24, 2024

Resolves #196

Updated to recursively search the annotation for any model that matches key. Note that there is a possibility that it could get the wrong field in case of union with complex types that both have the same key. Not sure how that case should be handled. For now, it picks first match.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cc6dc25) 97.61% compared to head (6bbd332) 97.69%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   97.61%   97.69%   +0.07%     
==========================================
  Files           5        5              
  Lines         336      347      +11     
  Branches       71       76       +5     
==========================================
+ Hits          328      339      +11     
  Misses          6        6              
  Partials        2        2              

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

@kschwab kschwab mentioned this pull request Jan 24, 2024
@hramezani
Copy link
Member

Thanks @kschwab for this PR 🙏

The test case that you've added is great. Could you please add another test case based on the code snippet in reported issue?

@kschwab
Copy link
Contributor Author

kschwab commented Jan 25, 2024

@hramezani good catch. #196 was slightly different issue compared to mine. I have pushed a fix and added test.

tests/test_settings.py Outdated Show resolved Hide resolved
@hramezani
Copy link
Member

Thanks @kschwab for this. I've just updated the tests.

@hramezani hramezani merged commit 40230ab into pydantic:main Jan 26, 2024
20 checks passed
@kschwab
Copy link
Contributor Author

kschwab commented Jan 26, 2024

Thanks @hramezani!

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.

Optional (or Union) types cannot be loaded from JSON secrets
2 participants