From 31d77ef6e4e64b1166cd0ecfb251ef4015e39f79 Mon Sep 17 00:00:00 2001 From: Max Marrone Date: Wed, 18 Dec 2024 17:00:03 -0500 Subject: [PATCH] Reuse existing TypeAdapter. --- robot-server/robot_server/runs/run_store.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/robot-server/robot_server/runs/run_store.py b/robot-server/robot_server/runs/run_store.py index 446a7a96482..3094b73b8ba 100644 --- a/robot-server/robot_server/runs/run_store.py +++ b/robot-server/robot_server/runs/run_store.py @@ -20,7 +20,7 @@ CommandErrorSlice, CommandStatus, ) -from opentrons.protocol_engine.commands import Command +from opentrons.protocol_engine.commands import Command, CommandAdapter from opentrons.protocol_engine.types import RunTimeParameter from opentrons_shared_data.errors.exceptions import ( @@ -51,6 +51,8 @@ _CACHE_ENTRIES = 32 +_rtp_list_adapter = TypeAdapter(list[RunTimeParameter]) + @dataclass(frozen=True) class RunResource: @@ -828,13 +830,9 @@ def _convert_state_to_sql_values( } -_command_type_adapter: TypeAdapter[Command] = TypeAdapter(Command) -_rtp_list_adapter = TypeAdapter(list[RunTimeParameter]) - - def _parse_command(json_str: str) -> Command: """Parse a JSON string from the database into a `Command`.""" - return json_to_pydantic(_command_type_adapter, json_str) + return json_to_pydantic(CommandAdapter, json_str) def _convert_commands_status_to_sql_command_status(