-
Notifications
You must be signed in to change notification settings - Fork 32
⬆️Pydantic V2: Diverse fixes after merges from master #6627
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
Changes from 14 commits
a945c6d
8ab4371
64cf5d0
4408874
67254ed
7cbf1e6
638ded4
b2074f7
87e7094
3baa3f8
b74a6cf
17cbd4f
0f5cd62
eca9d9a
6b18099
cf55b7b
6855b2e
a431816
1fe02f3
e8d7414
670200b
c0f2d97
c814e9b
e3b7ccc
2e20fb8
367c12b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,6 @@ | |
| from datetime import datetime | ||
| from typing import Any, Literal, TypeAlias | ||
|
|
||
| from models_library.folders import FolderID | ||
| from models_library.workspaces import WorkspaceID | ||
| from pydantic import ConfigDict, Field, HttpUrl, field_validator | ||
|
|
||
| from ..api_schemas_long_running_tasks.tasks import TaskGet | ||
|
|
@@ -24,9 +22,10 @@ | |
| none_to_empty_str_pre_validator, | ||
| null_or_none_str_to_none_validator, | ||
| ) | ||
| from ..utils.pydantic_tools_extension import FieldNotRequired | ||
| from ._base import EmptyModel, InputSchema, OutputSchema | ||
| from .folders import FolderID | ||
| from .permalinks import ProjectPermalink | ||
| from .workspaces import WorkspaceID | ||
|
|
||
|
|
||
| class ProjectCreateNew(InputSchema): | ||
|
|
@@ -74,14 +73,18 @@ class ProjectGet(OutputSchema): | |
| prj_owner: LowerCaseEmailStr | ||
| access_rights: dict[GroupIDStr, AccessRights] | ||
| tags: list[int] | ||
| classifiers: list[ClassifierID] = [] | ||
| classifiers: list[ClassifierID] = Field( | ||
| default_factory=list, json_schema_extra={"default": []} | ||
| ) | ||
| state: ProjectState | None = None | ||
| ui: EmptyModel | StudyUI | None = None | ||
| quality: dict[str, Any] = {} | ||
| quality: dict[str, Any] = Field( | ||
| default_factory=dict, json_schema_extra={"default": {}} | ||
| ) | ||
| dev: dict | None | ||
| permalink: ProjectPermalink = FieldNotRequired() | ||
| permalink: ProjectPermalink | None = None | ||
| workspace_id: WorkspaceID | None | ||
| folder_id: FolderID | None | ||
| folder_id: FolderID | None = None | ||
| trashed_at: datetime | None | ||
|
|
||
| _empty_description = field_validator("description", mode="before")( | ||
|
|
@@ -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": []} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? |
||
| ) | ||
| classifiers: list[ClassifierID] | None = Field( | ||
| default_factory=list, | ||
| default_factory=list, json_schema_extra={"default": []} | ||
| ) | ||
| ui: StudyUI | None = None | ||
| quality: dict[str, Any] = Field( | ||
| default_factory=dict, | ||
| default_factory=dict, json_schema_extra={"default": {}} | ||
| ) | ||
|
|
||
| _empty_is_none = field_validator("thumbnail", mode="before")( | ||
|
|
@@ -122,16 +127,16 @@ class ProjectReplace(InputSchema): | |
|
|
||
|
|
||
| class ProjectPatch(InputSchema): | ||
| name: ShortTruncatedStr = FieldNotRequired() | ||
| description: LongTruncatedStr = FieldNotRequired() | ||
| thumbnail: HttpUrl = FieldNotRequired() | ||
| access_rights: dict[GroupIDStr, AccessRights] = FieldNotRequired() | ||
| classifiers: list[ClassifierID] = FieldNotRequired() | ||
| dev: dict | None = FieldNotRequired() | ||
| ui: StudyUI | None = FieldNotRequired() | ||
| quality: dict[str, Any] = FieldNotRequired() | ||
|
|
||
| _empty_is_none = field_validator("thumbnail", allow_reuse=True, pre=True)( | ||
| name: ShortTruncatedStr | None = Field(default=None) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you add THOUGHT: I wonder if we should start using class MyModel(BaseModel):
foo: Annotated[LongTruncatedStr | None , Field(description="foo is the opposite of bar")] = NonePerhaps is an unnecessary burden ... it does not really pay off! |
||
| description: LongTruncatedStr | None = Field(default=None) | ||
| thumbnail: HttpUrl | None = Field(default=None) | ||
| access_rights: dict[GroupIDStr, AccessRights] | None = Field(default=None) | ||
| classifiers: list[ClassifierID] | None = Field(default=None) | ||
| dev: dict | None = Field(default=None) | ||
| ui: StudyUI | None = Field(default=None) | ||
| quality: dict[str, Any] | None = Field(default=None) | ||
|
|
||
| _empty_is_none = field_validator("thumbnail", mode="before")( | ||
| empty_str_to_none_pre_validator | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -518,6 +518,8 @@ def create_project_task(self, request: httpx.Request): | |
| "creationDate": "2018-07-01T11:13:43Z", | ||
| "lastChangeDate": "2018-07-01T11:13:43Z", | ||
| "prjOwner": "[email protected]", | ||
| "dev": None, | ||
| "trashed_at": None, | ||
| **project_create, | ||
| } | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.