Skip to content

Commit 277acc5

Browse files
author
Andrei Neagu
committed
fix typing and revert
1 parent 4e69b43 commit 277acc5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

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

1212
from models_library.basic_types import SHA1Str, VersionStr
13-
from models_library.utils.labels_annotations import from_labels, to_labels
13+
from models_library.utils.labels_annotations import (
14+
LabelsAnnotationsDict,
15+
from_labels,
16+
to_labels,
17+
)
1418
from pydantic import BaseModel, ConfigDict, Field
1519
from pydantic.networks import AnyUrl
1620

@@ -132,17 +136,16 @@ class OciImageSpecAnnotations(BaseModel):
132136

133137
@classmethod
134138
def from_labels_annotations(
135-
cls, labels: dict[str, str]
139+
cls, labels: LabelsAnnotationsDict
136140
) -> "OciImageSpecAnnotations":
137141
data = from_labels(labels, prefix_key=OCI_LABEL_PREFIX, trim_key_head=False)
138142
return cls.model_validate(data)
139143

140-
def to_labels_annotations(self) -> dict[str, str]:
141-
labels: dict[str, str] = to_labels(
144+
def to_labels_annotations(self) -> LabelsAnnotationsDict:
145+
return to_labels(
142146
self.model_dump(exclude_unset=True, by_alias=True, exclude_none=True),
143147
prefix_key=OCI_LABEL_PREFIX,
144148
)
145-
return labels
146149

147150

148151
class LabelSchemaAnnotations(BaseModel):

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class DockerComposeOverwriteConfig(ComposeSpecification):
7575
def create_default(
7676
cls, service_name: str | None = None
7777
) -> "DockerComposeOverwriteConfig":
78-
return cls.model_validate(
78+
model: "DockerComposeOverwriteConfig" = cls.model_validate(
7979
{
8080
"services": {
8181
service_name: {
@@ -86,12 +86,14 @@ def create_default(
8686
}
8787
}
8888
)
89+
return model
8990

9091
@classmethod
9192
def from_yaml(cls, path: Path) -> "DockerComposeOverwriteConfig":
9293
with path.open() as fh:
9394
data = yaml_safe_load(fh)
94-
return cls.model_validate(data)
95+
model: "DockerComposeOverwriteConfig" = cls.model_validate(data)
96+
return model
9597

9698

9799
class MetadataConfig(ServiceMetaDataPublished):

0 commit comments

Comments
 (0)