-
Notifications
You must be signed in to change notification settings - Fork 105
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
Disable warnings from model_dump #1214
Disable warnings from model_dump #1214
Conversation
When using model_dump to access attributes in experimental template decorator code, a warning is being raised due to the strings we place in the Pydantic objects not matching the declared field types. Disable these warnings. Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1214 +/- ##
=======================================
+ Coverage 81.7% 86.0% +4.2%
=======================================
Files 54 60 +6
Lines 4208 4040 -168
Branches 889 840 -49
=======================================
+ Hits 3439 3475 +36
+ Misses 574 392 -182
+ Partials 195 173 -22 ☔ View full report in Codecov by Sentry. |
508d71a
to
4037c57
Compare
tests/conftest.py
Outdated
|
||
|
||
@pytest.fixture(autouse=True) | ||
def fail_on_user_warnings(): |
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'm in two minds about this fixture — it does catch this issue and prevent any similar issues in future, but I don't like having to suppress the one deprecation warning that Pydantic appears to have accidentally left as a UserWarning. LMK if you'd rather leave it out, it's a separate commit so easy to revert.
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 would rather not optimise early here as it might get difficult/annoying when we move Hera's core code to Pydantic V2
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.
Sure thing. Removed the fixture.
4037c57
to
26e6f12
Compare
Pull Request Checklist
Description of PR
Currently, using Pydantic V2 with the Input/Output mixin types and a non-
str
field prints aUserWarning
when the class is declared, of the form "UserWarning: Pydantic serializer warning: Expectedint
but gotstr
with value'{{...}}'
- serialized value may not be as expected". This is caused by usingmodel_dump
on an object constructed with all string values, i.e. one which does not pass the type-checking performed by the method, as part of class creation.This PR just adds
warnings="none"
to the two uses ofmodel_dump
, to disable these warnings.