-
Notifications
You must be signed in to change notification settings - Fork 27
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
⬆️Pydantic V2: Diverse fixes after merges from master #6627
⬆️Pydantic V2: Diverse fixes after merges from master #6627
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.
thanks
304d440
to
3baa3f8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## pydantic_v2_migration_do_not_squash_updates #6627 +/- ##
===============================================================================
- Coverage 70.69% 70.55% -0.15%
===============================================================================
Files 1029 922 -107
Lines 46799 42955 -3844
Branches 1243 434 -809
===============================================================================
- Hits 33086 30308 -2778
+ Misses 13492 12555 -937
+ Partials 221 92 -129
*This pull request uses carry forward flags. Click here to find out more.
Continue to review 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.
Please double check my highlights
packages/models-library/src/models_library/api_schemas_webserver/projects.py
Outdated
Show resolved
Hide resolved
packages/models-library/src/models_library/utils/pydantic_tools_extension.py
Outdated
Show resolved
Hide resolved
Quality Gate failedFailed conditions |
9e76d4f
into
ITISFoundation:pydantic_v2_migration_do_not_squash_updates
@@ -107,13 +110,15 @@ class ProjectReplace(InputSchema): | |||
last_change_date: DateTimeStr | |||
workbench: NodesDict | |||
access_rights: dict[GroupIDStr, AccessRights] | |||
tags: list[int] | None = [] | |||
tags: list[int] | None = Field( | |||
default_factory=list, json_schema_extra={"default": []} |
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 wonder if the rest noticed this. perhaps add it in the description of the PR ?
quality: dict[str, Any] = FieldNotRequired() | ||
|
||
_empty_is_none = field_validator("thumbnail", allow_reuse=True, pre=True)( | ||
name: ShortTruncatedStr | None = Field(default=None) |
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.
Why you add Field
when we only look for the default?
THOUGHT: I wonder if we should start using Annotated
instead of abusing of the "exception to the rule" of adding a default (i.e. Field
) that is not an instance of the type annotated. It kind of similar to the story with FieldRequired
that exploited an edge case that now was removed.
class MyModel(BaseModel):
foo: Annotated[LongTruncatedStr | None , Field(description="foo is the opposite of bar")] = None
Perhaps is an unnecessary burden ... it does not really pay off!
@@ -27,6 +28,8 @@ | |||
"invoice_pdf_url": None, | |||
"initiated_at": "2023-09-27T10:00:00", | |||
"state": PaymentTransactionState.PENDING, | |||
"completed_at": None, |
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.
this is fine
What do these changes do?
FieldNotRequired
this is not supported anymorein pydantic V1 would validate when
my_int
was "forgotten" and set it asNone
. This is not anymore the case in V2 which is the expected behavior.Also in V2,
FieldNotRequired
, which was abusing that concept is not supported anymore.@matusdrobuliak66 @pcrespov Please check:
services/payments/src/simcore_service_payments/models/db.py
changes in example forPaymentsTransactionsDB
and 'PaymentsMethodsDB' that were missing valuesRelated issue/s
How to test
Dev-ops checklist