Skip to content

Commit a0262a2

Browse files
continue mypy
1 parent e77282d commit a0262a2

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

services/clusters-keeper/src/simcore_service_clusters_keeper/core/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
def create_app(settings: ApplicationSettings) -> FastAPI:
28-
logger.info("app settings: %s", settings.json(indent=1))
28+
logger.info("app settings: %s", settings.model_dump_json(indent=1))
2929

3030
app = FastAPI(
3131
debug=settings.CLUSTERS_KEEPER_DEBUG,

services/clusters-keeper/tests/unit/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def mocked_ec2_server_envs(
8181
# NOTE: overrides the EC2Settings with what clusters-keeper expects
8282
changed_envs: EnvVarsDict = {
8383
f"{CLUSTERS_KEEPER_ENV_PREFIX}{k}": v
84-
for k, v in mocked_ec2_server_settings.dict().items()
84+
for k, v in mocked_ec2_server_settings.model_dump().items()
8585
}
8686
return setenvs_from_dict(monkeypatch, changed_envs)
8787

services/clusters-keeper/tests/unit/test_modules_dask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
NoAuthentication,
1313
TLSAuthentication,
1414
)
15-
from pydantic import AnyUrl, parse_obj_as
15+
from pydantic import AnyUrl, TypeAdapter
1616
from simcore_service_clusters_keeper.modules.dask import (
1717
is_scheduler_busy,
1818
ping_scheduler,
@@ -38,7 +38,7 @@ async def test_ping_scheduler_non_existing_scheduler(
3838
):
3939
assert (
4040
await ping_scheduler(
41-
parse_obj_as(AnyUrl, f"tcp://{faker.ipv4()}:{faker.port_number()}"),
41+
TypeAdapter(AnyUrl).validate_python(f"tcp://{faker.ipv4()}:{faker.port_number()}"),
4242
authentication,
4343
)
4444
is False
@@ -48,7 +48,7 @@ async def test_ping_scheduler_non_existing_scheduler(
4848
async def test_ping_scheduler(dask_spec_local_cluster: SpecCluster):
4949
assert (
5050
await ping_scheduler(
51-
parse_obj_as(AnyUrl, dask_spec_local_cluster.scheduler_address),
51+
TypeAdapter(AnyUrl).validate_python(dask_spec_local_cluster.scheduler_address),
5252
NoAuthentication(),
5353
)
5454
is True
@@ -71,7 +71,7 @@ async def test_is_scheduler_busy(
7171
dask_spec_cluster_client: distributed.Client,
7272
):
7373
# nothing runs right now
74-
scheduler_address = parse_obj_as(AnyUrl, dask_spec_local_cluster.scheduler_address)
74+
scheduler_address = TypeAdapter(AnyUrl).validate_python(dask_spec_local_cluster.scheduler_address)
7575
assert await is_scheduler_busy(scheduler_address, NoAuthentication()) is False
7676
_SLEEP_TIME = 5
7777

services/clusters-keeper/tests/unit/test_modules_rabbitmq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async def test_post_message(
116116
f"--> checking for message in rabbit exchange {rabbit_message.channel_name}, {attempt.retry_state.retry_object.statistics}"
117117
)
118118
mocked_message_handler.assert_called_once_with(
119-
rabbit_message.json().encode()
119+
rabbit_message.model_dump_json().encode()
120120
)
121121
print("... message received")
122122

services/clusters-keeper/tests/unit/test_utils_clusters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
TLSAuthentication,
2424
)
2525
from models_library.utils.json_serialization import json_dumps
26-
from pydantic import ByteSize, parse_obj_as
26+
from pydantic import ByteSize, TypeAdapter
2727
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
2828
from simcore_service_clusters_keeper.core.settings import ApplicationSettings
2929
from simcore_service_clusters_keeper.utils.clusters import (
@@ -178,7 +178,7 @@ def test_create_startup_script_script_size_below_16kb(
178178
script_size_in_bytes = len(startup_script.encode("utf-8"))
179179

180180
print(
181-
f"current script size is {parse_obj_as(ByteSize, script_size_in_bytes).human_readable()}"
181+
f"current script size is {TypeAdapter(ByteSize).validate_python(script_size_in_bytes).human_readable()}"
182182
)
183183
# NOTE: EC2 user data cannot be above 16KB, we keep some margin here
184184
assert script_size_in_bytes < 15 * 1024

0 commit comments

Comments
 (0)