Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Feb 8, 2024
1 parent f76f6c1 commit dbe8417
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions api/src/opentrons/protocols/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import traceback
from io import BytesIO
from zipfile import ZipFile
from typing import Any, Dict, Optional, Union, Tuple, TYPE_CHECKING, cast
from typing import Any, Dict, Optional, Union, Tuple, TYPE_CHECKING

import jsonschema # type: ignore

Expand Down Expand Up @@ -500,17 +500,6 @@ def _has_api_v1_imports(parsed: ast.Module) -> bool:
return bool(v1_markers.intersection(opentrons_imports))


def _strvalue_from_str_or_byte_dict(
dct: Union[Dict[str, str], Dict[bytes, bytes]], key: str
) -> Optional[str]:
key_bytes = key.encode("utf-8")
val_bytes = cast(Dict[bytes, bytes], dct).get(key_bytes, None)
val_str = cast(Dict[str, str], dct).get(key, None)
if val_bytes:
return val_bytes.decode("utf-8")
return val_str


def _version_from_static_python_info(
static_python_info: StaticPythonInfo,
) -> Optional[APIVersion]:
Expand All @@ -519,12 +508,8 @@ def _version_from_static_python_info(
If the protocol doesn't declare apiLevel at all, return None.
If the protocol declares apiLevel incorrectly, raise a ValueError.
"""
from_requirements = _strvalue_from_str_or_byte_dict(
static_python_info.requirements or {}, "apiLevel"
)
from_metadata = _strvalue_from_str_or_byte_dict(
static_python_info.metadata or {}, "apiLevel"
)
from_requirements = (static_python_info.requirements or {}).get("apiLevel", None)
from_metadata = (static_python_info.metadata or {}).get("apiLevel", None)

requested_level = from_requirements or from_metadata
if requested_level is None:
Expand Down Expand Up @@ -553,9 +538,7 @@ def robot_type_from_python_identifier(python_robot_type: str) -> RobotType:
def _robot_type_from_static_python_info(
static_python_info: StaticPythonInfo,
) -> RobotType:
python_robot_type = _strvalue_from_str_or_byte_dict(
static_python_info.requirements or {}, "robotType"
)
python_robot_type = (static_python_info.requirements or {}).get("robotType", None)
if python_robot_type is None:
return "OT-2 Standard"
else:
Expand Down

0 comments on commit dbe8417

Please sign in to comment.