-
-
Notifications
You must be signed in to change notification settings - Fork 64
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 nested model problem when case_sensitive=False #34
Fix nested model problem when case_sensitive=False #34
Conversation
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 LGTM.
pydantic_settings/sources.py
Outdated
if not field.annotation: | ||
values[name] = value | ||
continue |
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.
are you sure this is necessary? It looks like where this is called field.annotations
is always a BaseModel
- also the next line assumes field.annotation.model_fields
always exists.
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.
It's here only to make mypy happy
Item "None" of "Optional[Type[Any]]" has no attribute "model_fields"
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.
ok, please add a comment saying that, and also support the case where field.annotations
is not None but is not a BaseModel
- e.g. has no .model_fields
attribute.
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.
Done!
@samuelcolvin I've also added a comment to ignore fields with |
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 #34 +/- ##
==========================================
- Coverage 96.00% 95.25% -0.75%
==========================================
Files 5 5
Lines 275 295 +20
Branches 67 74 +7
==========================================
+ Hits 264 281 +17
- Misses 10 12 +2
- Partials 1 2 +1
☔ 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.
LGTM.
|
||
By having the following models: | ||
|
||
class SubSubSub(BaseModel): |
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.
one comment (doesn't matter much here since I guess we won't add this to the documentation) - if you want code in docsting, please use markdown with code fences so they examples render properly.
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.
Nice one. Done!
Fixes #9