Skip to content

Commit a17012f

Browse files
Revert use of pydantic_core.from_json() in labware def validation.
from_json() appears not to be *exactly* a drop-in replacement for json.loads(): it raises different exceptions for invalid input. We could certainly account for that, but for better testing and reviewing, it seems like it should be in a different PR at this point. I'm not reverting the multi-schema additions to this function because there doesn't seem to be a problem with those.
1 parent 212e876 commit a17012f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

api/src/opentrons/protocols/labware.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77
from typing import Any, AnyStr, Dict, Optional, Union, List
88

9-
from pydantic_core import from_json
109
import jsonschema # type: ignore
1110

1211
from opentrons_shared_data import load_shared_data, get_shared_data_root
@@ -128,7 +127,7 @@ def save_definition(
128127

129128

130129
def verify_definition(
131-
contents: Union[AnyStr, LabwareDefinition, Dict[str, Any]],
130+
contents: Union[AnyStr, LabwareDefinition, Dict[str, Any]]
132131
) -> LabwareDefinition:
133132
"""Verify that an input string is a labware definition and return it.
134133
@@ -140,14 +139,14 @@ def verify_definition(
140139
:returns: The parsed definition
141140
"""
142141
schemata_by_version = {
143-
2: from_json(load_shared_data("labware/schemas/2.json").decode("utf-8")),
144-
3: from_json(load_shared_data("labware/schemas/3.json").decode("utf-8")),
142+
2: json.loads(load_shared_data("labware/schemas/2.json").decode("utf-8")),
143+
3: json.loads(load_shared_data("labware/schemas/3.json").decode("utf-8")),
145144
}
146145

147146
if isinstance(contents, dict):
148147
to_return = contents
149148
else:
150-
to_return = from_json(contents)
149+
to_return = json.loads(contents)
151150
try:
152151
schema_version = to_return["schemaVersion"]
153152
schema = schemata_by_version[schema_version]

0 commit comments

Comments
 (0)