Skip to content

Commit 927b67e

Browse files
committed
@sanderegg, @GitHK review: import unset constant
1 parent 0b83488 commit 927b67e

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

packages/common-library/src/common_library/basic_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from enum import StrEnum
2+
from typing import Any
23

34
from pydantic_core import PydanticUndefined
45

56
# SEE https://github.com/fastapi/fastapi/blob/master/fastapi/_compat.py#L75-L78
6-
#
7-
# Use as default when default_factory
87
Undefined = PydanticUndefined
8+
UNSET: Any = Undefined
9+
# Use `UNSET` as default when default_factory
10+
# SEE https://github.com/ITISFoundation/osparc-simcore/pull/6882
911

1012

1113
class LogLevel(StrEnum):

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from typing import Annotated, Any
22

3-
from common_library.basic_types import Undefined
3+
from common_library.basic_types import UNSET
44
from pydantic import AnyUrl, BaseModel, Field
55

6-
_Unset: Any = Undefined
7-
86

97
class AppStatusCheck(BaseModel):
108
app_name: str = Field(..., description="Application name")
@@ -16,7 +14,7 @@ class AppStatusCheck(BaseModel):
1614
description="Other backend services connected from this service",
1715
json_schema_extra={"default": {}},
1816
),
19-
] = _Unset
17+
] = UNSET
2018

2119
sessions: Annotated[
2220
dict[str, Any] | None,
@@ -25,7 +23,7 @@ class AppStatusCheck(BaseModel):
2523
description="Client sessions info. If single session per app, then is denoted as main",
2624
json_schema_extra={"default": {}},
2725
),
28-
] = _Unset
26+
] = UNSET
2927

3028
url: AnyUrl | None = Field(
3129
default=None,

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Annotated, Any, Final, TypeAlias
88
from uuid import UUID
99

10-
from common_library.basic_types import Undefined
10+
from common_library.basic_types import UNSET
1111
from models_library.basic_types import ConstrainedStr
1212
from models_library.folders import FolderID
1313
from models_library.workspaces import WorkspaceID
@@ -25,9 +25,6 @@
2525
none_to_empty_str_pre_validator,
2626
)
2727

28-
_Unset: Any = Undefined
29-
30-
3128
ProjectID: TypeAlias = UUID
3229
ClassifierID: TypeAlias = str
3330

@@ -155,7 +152,7 @@ class Project(BaseProjectModel):
155152
description="Contains the reference to the project classifiers",
156153
examples=["some:id:to:a:classifier"],
157154
),
158-
] = _Unset
155+
] = UNSET
159156

160157
# Project state (SEE projects_state.py)
161158
state: ProjectState | None = None

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Annotated, Any, TypeAlias, Union
66

7-
from common_library.basic_types import Undefined
7+
from common_library.basic_types import UNSET
88
from pydantic import (
99
BaseModel,
1010
ConfigDict,
@@ -31,8 +31,6 @@
3131
from .projects_state import RunningState
3232
from .services import ServiceKey, ServiceVersion
3333

34-
_Unset: Any = Undefined
35-
3634
InputTypes = Union[
3735
# NOTE: WARNING the order in Union[*] below matters!
3836
StrictBool,
@@ -164,7 +162,7 @@ class Node(BaseModel):
164162
inputs: Annotated[
165163
InputsDict | None,
166164
Field(default_factory=dict, description="values of input properties"),
167-
] = _Unset
165+
] = UNSET
168166

169167
inputs_required: Annotated[
170168
list[InputID],
@@ -173,7 +171,7 @@ class Node(BaseModel):
173171
description="Defines inputs that are required in order to run the service",
174172
alias="inputsRequired",
175173
),
176-
] = _Unset
174+
] = UNSET
177175

178176
inputs_units: Annotated[
179177
dict[InputID, UnitStr] | None,
@@ -198,13 +196,13 @@ class Node(BaseModel):
198196
description="node IDs of where the node is connected to",
199197
alias="inputNodes",
200198
),
201-
] = _Unset
199+
] = UNSET
202200

203201
# OUTPUT PORTS ---
204202
outputs: Annotated[
205203
OutputsDict | None,
206204
Field(default_factory=dict, description="values of output properties"),
207-
] = _Unset
205+
] = UNSET
208206

209207
output_node: Annotated[
210208
bool | None, Field(deprecated=True, alias="outputNode")
@@ -236,7 +234,7 @@ class Node(BaseModel):
236234
state: Annotated[
237235
NodeState | None,
238236
Field(default_factory=NodeState, description="The node's state object"),
239-
] = _Unset
237+
] = UNSET
240238

241239
boot_options: Annotated[
242240
dict[EnvVarKey, str] | None,

packages/service-integration/src/service_integration/osparc_config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pathlib import Path
1717
from typing import Annotated, Any, Final, Literal
1818

19-
from common_library.basic_types import Undefined
19+
from common_library.basic_types import UNSET
2020
from models_library.basic_types import SHA256Str
2121
from models_library.callbacks_mapping import CallbacksMapping
2222
from models_library.service_settings_labels import (
@@ -65,8 +65,6 @@
6565
ServiceType.DYNAMIC: DYNAMIC_SERVICE_KEY_FORMAT,
6666
}
6767

68-
_Unset: Any = Undefined
69-
7068

7169
class DockerComposeOverwriteConfig(ComposeSpecification):
7270
"""Content of docker-compose.overwrite.yml configuration file"""
@@ -220,7 +218,7 @@ class RuntimeConfig(BaseModel):
220218

221219
callbacks_mapping: Annotated[
222220
CallbacksMapping | None, Field(default_factory=dict)
223-
] = _Unset
221+
] = UNSET
224222

225223
paths_mapping: PathMappingsLabel | None = None
226224

@@ -232,7 +230,7 @@ class RuntimeConfig(BaseModel):
232230

233231
containers_allowed_outgoing_internet: set[str] | None = None
234232

235-
settings: Annotated[list[SettingsItem], Field(default_factory=list)] = _Unset
233+
settings: Annotated[list[SettingsItem], Field(default_factory=list)] = UNSET
236234

237235
@model_validator(mode="before")
238236
@classmethod

0 commit comments

Comments
 (0)