Skip to content
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

♻️ fixes mypy issues in models-library #4533

4 changes: 4 additions & 0 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ jobs:
- 'packages/postgres-database/**'
- 'packages/pytest-simcore/**'
- 'services/docker-compose*'
- 'scripts/mypy/*'
- 'mypy.ini'
postgres-database:
- 'packages/postgres-database/**'
- 'packages/pytest-simcore/**'
Expand Down Expand Up @@ -1391,6 +1393,8 @@ jobs:
run: ./ci/helpers/show_system_versions.bash
- name: install
run: ./ci/github/unit-testing/models-library.bash install
- name: typecheck
run: ./ci/github/unit-testing/models-library.bash typecheck
- name: test
run: ./ci/github/unit-testing/models-library.bash test
- uses: codecov/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions packages/models-library/src/models_library/aiodocker_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


class AioDockerContainerSpec(ContainerSpec):
Env: dict[str, str | None] | None = Field(
None,
Env: dict[str, str | None] | None = Field( # type: ignore
matusdrobuliak66 marked this conversation as resolved.
Show resolved Hide resolved
default=None,
description="aiodocker expects here a dictionary and re-convert it back internally`.\n",
)

Expand All @@ -37,7 +37,7 @@ class AioDockerResources1(Resources1):
None, description="Define resources reservation.", alias="Reservations"
)

class Config(Resources1.Config):
class Config(Resources1.Config): # type: ignore
allow_population_by_field_name = True


Expand All @@ -55,6 +55,6 @@ class AioDockerTaskSpec(TaskSpec):
class AioDockerServiceSpec(ServiceSpec):
TaskTemplate: AioDockerTaskSpec | None = None

class Config(ServiceSpec.Config):
matusdrobuliak66 marked this conversation as resolved.
Show resolved Hide resolved
class Config(ServiceSpec.Config): # type: ignore
alias_generator = to_snake_case
allow_population_by_field_name = True
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TaskProgress(BaseModel):
"""

message: ProgressMessage = Field(default="")
percent: ProgressPercent = Field(default=0.0)
percent: ProgressPercent = Field(default=ProgressPercent(0.0))

@validate_arguments
def update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class FileMetaDataGet(BaseModel):
)
created_at: datetime
last_modified: datetime
file_size: ByteSize = Field(-1, description="File size in bytes (-1 means invalid)")
file_size: ByteSize | int = Field(
default=-1, description="File size in bytes (-1 means invalid)"
)
entity_tag: ETag | None = Field(
default=None,
description="Entity tag (or ETag), represents a specific version of the file, None if invalid upload or datcore",
Expand Down
2 changes: 1 addition & 1 deletion packages/models-library/src/models_library/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from models_library.generated_models.docker_rest_api import Task
from models_library.products import ProductName
from models_library.projects import ProjectID
from models_library.projects_nodes import NodeID
from models_library.projects_nodes_io import NodeID
from models_library.users import UserID
from pydantic import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Iterator, Optional
from typing import Iterator

from ...projects_nodes import OutputsDict
from ...projects_nodes import OutputID, OutputsDict
from ...services import LATEST_INTEGRATION_VERSION, ServiceDockerData, ServiceType
from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX
from .._utils import OM, FunctionServices, create_fake_thumbnail_url


def create_metadata(type_name: str, prefix: Optional[str] = None) -> ServiceDockerData:
def create_metadata(type_name: str, prefix: str | None = None) -> ServiceDockerData:
prefix = prefix or type_name
LABEL = f"{type_name.capitalize()} iterator"
return ServiceDockerData.parse_obj(
Expand Down Expand Up @@ -56,15 +56,14 @@ def create_metadata(type_name: str, prefix: Optional[str] = None) -> ServiceDock
def _linspace_func(
linspace_start: int = 0, linspace_stop: int = 1, linspace_step: int = 1
) -> Iterator[int]:
for value in range(linspace_start, linspace_stop, linspace_step):
yield value
yield from range(linspace_start, linspace_stop, linspace_step)


def _linspace_generator(**kwargs) -> Iterator[OutputsDict]:
# Maps generator with iterable outputs.
# Can have non-iterable outputs as well
for value in _linspace_func(**kwargs):
yield {"out_1": value}
yield {OutputID("out_1"): value}


services = FunctionServices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import schema_of

from ...projects_nodes import OutputsDict
from ...projects_nodes import OutputID, OutputsDict
from ...services import LATEST_INTEGRATION_VERSION, ServiceDockerData, ServiceType
from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX
from .._utils import EN, OM, FunctionServices, create_fake_thumbnail_url
Expand Down Expand Up @@ -99,7 +99,11 @@ def _sensitivity_generator(
for i, paramtestplus, paramtestminus in eval_sensitivity(
paramrefs=paramrefs, paramdiff=paramdiff, diff_or_fact=diff_or_fact
):
yield {"out_1": i, "out_2": paramtestplus, "out_3": paramtestminus}
yield {
OutputID("out_1"): i,
OutputID("out_2"): paramtestplus,
OutputID("out_3"): paramtestminus,
}


services = FunctionServices()
Expand Down
Loading