Skip to content

Commit 96a93ac

Browse files
fix url types
1 parent b62770d commit 96a93ac

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

packages/models-library/src/models_library/basic_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ class LongTruncatedStr(ConstrainedStr):
130130
IdInt: TypeAlias = PositiveInt
131131
PrimaryKeyInt: TypeAlias = PositiveInt
132132

133-
AnyUrl = Annotated[str, pydantic.AnyUrl]
134-
135133
AnyHttpUrl = Annotated[str, pydantic.AnyHttpUrl]
136134

137135
HttpUrl = Annotated[str, pydantic.HttpUrl]

packages/models-library/src/models_library/projects_nodes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
BaseModel,
1010
ConfigDict,
1111
Field,
12+
HttpUrl,
1213
Json,
1314
StrictBool,
1415
StrictFloat,
@@ -17,7 +18,7 @@
1718
field_validator,
1819
)
1920

20-
from .basic_types import EnvVarKey, HttpUrl, KeyIDStr
21+
from .basic_types import EnvVarKey, KeyIDStr
2122
from .projects_access import AccessEnum
2223
from .projects_nodes_io import (
2324
DatCoreFileLink,
@@ -137,7 +138,7 @@ class Node(BaseModel):
137138
description="the node progress value (deprecated in DB, still used for API only)",
138139
deprecated=True,
139140
)
140-
thumbnail: HttpUrl | None = Field(
141+
thumbnail: Annotated[str, HttpUrl] | None = Field(
141142
default=None,
142143
description="url of the latest screenshot of the node",
143144
examples=["https://placeimg.com/171/96/tech/grayscale/?0.jpg"],

packages/models-library/src/models_library/projects_nodes_io.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from typing import Annotated, TypeAlias
1212
from uuid import UUID
1313

14-
from models_library.basic_types import AnyUrl, ConstrainedStr, KeyIDStr
14+
from models_library.basic_types import ConstrainedStr, KeyIDStr
1515
from pydantic import (
16+
AnyUrl,
1617
BaseModel,
1718
ConfigDict,
1819
Field,
@@ -122,7 +123,7 @@ class PortLink(BaseModel):
122123
class DownloadLink(BaseModel):
123124
"""I/O port type to hold a generic download link to a file (e.g. S3 pre-signed link, etc)"""
124125

125-
download_link: AnyUrl = Field(..., alias="downloadLink")
126+
download_link: Annotated[str, AnyUrl] = Field(..., alias="downloadLink")
126127
label: str | None = Field(default=None, description="Display name")
127128
model_config = ConfigDict(
128129
extra="forbid",

packages/models-library/src/models_library/rest_pagination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Annotated, Final, Generic, TypeAlias, TypeVar
22

33
from pydantic import (
4+
AnyHttpUrl,
45
BaseModel,
56
ConfigDict,
67
Field,
@@ -11,7 +12,6 @@
1112
field_validator,
1213
)
1314

14-
from .basic_types import AnyHttpUrl
1515
from .utils.common_validators import none_to_empty_list_pre_validator
1616

1717
# Default limit values
@@ -92,7 +92,7 @@ class PageRefs(BaseModel, Generic[RefT]):
9292
model_config = ConfigDict(extra="forbid")
9393

9494

95-
class PageLinks(PageRefs[AnyHttpUrl]):
95+
class PageLinks(PageRefs[Annotated[str, AnyHttpUrl]]):
9696
...
9797

9898

packages/models-library/src/models_library/services_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from pydantic import BaseModel, ConfigDict, Field, field_validator
1+
from typing import Annotated
2+
from pydantic import BaseModel, ConfigDict, Field, HttpUrl, field_validator
23

3-
from .basic_types import HttpUrl
44
from .services_types import ServiceKey, ServiceVersion
55
from .utils.common_validators import empty_str_to_none_pre_validator
66

@@ -26,7 +26,7 @@ class ServiceBaseDisplay(BaseModel):
2626
description="Display name: short, human readable name for the node",
2727
examples=["Fast Counter"],
2828
)
29-
thumbnail: HttpUrl | None = Field(
29+
thumbnail: Annotated[str, HttpUrl] | None = Field(
3030
None,
3131
description="url to the thumbnail",
3232
examples=[

packages/models-library/src/models_library/services_metadata_editable.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# mypy: disable-error-code=truthy-function
22
from datetime import datetime
3-
from typing import Any
3+
from typing import Annotated, Any
44

5-
from pydantic import ConfigDict, Field
5+
from pydantic import ConfigDict, Field, HttpUrl
66

7-
from .basic_types import HttpUrl
87
from .services_base import ServiceBaseDisplay
98
from .services_constants import LATEST_INTEGRATION_VERSION
109
from .services_enums import ServiceType
@@ -20,7 +19,7 @@
2019
class ServiceMetaDataEditable(ServiceBaseDisplay):
2120
# Overrides ServiceBaseDisplay fields to Optional for a partial update
2221
name: str | None # type: ignore[assignment]
23-
thumbnail: HttpUrl | None
22+
thumbnail: Annotated[str, HttpUrl] | None
2423
description: str | None # type: ignore[assignment]
2524
description_ui: bool = False
2625
version_display: str | None = None

0 commit comments

Comments
 (0)