Skip to content

Commit

Permalink
Reuse existing TypeAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 18, 2024
1 parent 60398ea commit 31d77ef
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions robot-server/robot_server/runs/run_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -51,6 +51,8 @@

_CACHE_ENTRIES = 32

_rtp_list_adapter = TypeAdapter(list[RunTimeParameter])


@dataclass(frozen=True)
class RunResource:
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 31d77ef

Please sign in to comment.