Skip to content

Commit

Permalink
Update type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Oct 28, 2024
1 parent 881d50a commit 93b408d
Show file tree
Hide file tree
Showing 73 changed files with 134 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class CloseLidResult(BaseModel):
"""Result data from closing the lid on an aborbance reading."""


class CloseLidImpl(
AbstractCommandImpl[CloseLidParams, SuccessData[CloseLidResult, None]]
):
class CloseLidImpl(AbstractCommandImpl[CloseLidParams, SuccessData[CloseLidResult]]):
"""Execution implementation of closing the lid on an Absorbance Reader."""

def __init__(
Expand All @@ -53,9 +51,7 @@ def __init__(
self._equipment = equipment
self._labware_movement = labware_movement

async def execute(
self, params: CloseLidParams
) -> SuccessData[CloseLidResult, None]:
async def execute(self, params: CloseLidParams) -> SuccessData[CloseLidResult]:
"""Execute the close lid command."""
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InitializeResult(BaseModel):


class InitializeImpl(
AbstractCommandImpl[InitializeParams, SuccessData[InitializeResult, None]]
AbstractCommandImpl[InitializeParams, SuccessData[InitializeResult]]
):
"""Execution implementation of initializing an Absorbance Reader."""

Expand All @@ -50,9 +50,7 @@ def __init__(
self._state_view = state_view
self._equipment = equipment

async def execute(
self, params: InitializeParams
) -> SuccessData[InitializeResult, None]:
async def execute(self, params: InitializeParams) -> SuccessData[InitializeResult]:
"""Initiate a single absorbance measurement."""
abs_reader_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OpenLidResult(BaseModel):
"""Result data from opening the lid on an aborbance reading."""


class OpenLidImpl(AbstractCommandImpl[OpenLidParams, SuccessData[OpenLidResult, None]]):
class OpenLidImpl(AbstractCommandImpl[OpenLidParams, SuccessData[OpenLidResult]]):
"""Execution implementation of opening the lid on an Absorbance Reader."""

def __init__(
Expand All @@ -52,7 +52,7 @@ def __init__(
self._equipment = equipment
self._labware_movement = labware_movement

async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult, None]:
async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult]:
"""Move the absorbance reader lid from the module to the lid dock."""
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ReadAbsorbanceResult(BaseModel):


class ReadAbsorbanceImpl(
AbstractCommandImpl[ReadAbsorbanceParams, SuccessData[ReadAbsorbanceResult, None]]
AbstractCommandImpl[ReadAbsorbanceParams, SuccessData[ReadAbsorbanceResult]]
):
"""Execution implementation of an Absorbance Reader measurement."""

Expand All @@ -65,7 +65,7 @@ def __init__(

async def execute( # noqa: C901
self, params: ReadAbsorbanceParams
) -> SuccessData[ReadAbsorbanceResult, None]:
) -> SuccessData[ReadAbsorbanceResult]:
"""Initiate an absorbance measurement."""
abs_reader_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/aspirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AspirateResult(BaseLiquidHandlingResult, DestinationPositionResult):


_ExecuteReturn = Union[
SuccessData[AspirateResult, None],
SuccessData[AspirateResult],
DefinedErrorData[OverpressureError],
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AspirateInPlaceResult(BaseLiquidHandlingResult):


_ExecuteReturn = Union[
SuccessData[AspirateInPlaceResult, None],
SuccessData[AspirateInPlaceResult],
DefinedErrorData[OverpressureError],
]

Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/blow_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BlowOutResult(DestinationPositionResult):


_ExecuteReturn = Union[
SuccessData[BlowOutResult, None],
SuccessData[BlowOutResult],
DefinedErrorData[OverpressureError],
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BlowOutInPlaceResult(BaseModel):


_ExecuteReturn = Union[
SuccessData[BlowOutInPlaceResult, None],
SuccessData[BlowOutInPlaceResult],
DefinedErrorData[OverpressureError],
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class CalibrateGripperResult(BaseModel):


class CalibrateGripperImplementation(
AbstractCommandImpl[
CalibrateGripperParams, SuccessData[CalibrateGripperResult, None]
]
AbstractCommandImpl[CalibrateGripperParams, SuccessData[CalibrateGripperResult]]
):
"""The implementation of a `calibrateGripper` command."""

Expand All @@ -87,7 +85,7 @@ def __init__(

async def execute(
self, params: CalibrateGripperParams
) -> SuccessData[CalibrateGripperResult, None]:
) -> SuccessData[CalibrateGripperResult]:
"""Execute a `calibrateGripper` command.
1. Move from the current location to the calibration area on the deck.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CalibrateModuleResult(BaseModel):


class CalibrateModuleImplementation(
AbstractCommandImpl[CalibrateModuleParams, SuccessData[CalibrateModuleResult, None]]
AbstractCommandImpl[CalibrateModuleParams, SuccessData[CalibrateModuleResult]]
):
"""CalibrateModule command implementation."""

Expand All @@ -64,7 +64,7 @@ def __init__(

async def execute(
self, params: CalibrateModuleParams
) -> SuccessData[CalibrateModuleResult, None]:
) -> SuccessData[CalibrateModuleResult]:
"""Execute calibrate-module command."""
ot3_api = ensure_ot3_hardware(
self._hardware_api,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class CalibratePipetteResult(BaseModel):


class CalibratePipetteImplementation(
AbstractCommandImpl[
CalibratePipetteParams, SuccessData[CalibratePipetteResult, None]
]
AbstractCommandImpl[CalibratePipetteParams, SuccessData[CalibratePipetteResult]]
):
"""CalibratePipette command implementation."""

Expand All @@ -49,7 +47,7 @@ def __init__(

async def execute(
self, params: CalibratePipetteParams
) -> SuccessData[CalibratePipetteResult, None]:
) -> SuccessData[CalibratePipetteResult]:
"""Execute calibrate-pipette command."""
# TODO (tz, 20-9-22): Add a better solution to determine if a command can be executed on an OT-3/OT-2
ot3_api = ensure_ot3_hardware(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MoveToMaintenancePositionResult(BaseModel):
class MoveToMaintenancePositionImplementation(
AbstractCommandImpl[
MoveToMaintenancePositionParams,
SuccessData[MoveToMaintenancePositionResult, None],
SuccessData[MoveToMaintenancePositionResult],
]
):
"""Calibration set up position command implementation."""
Expand All @@ -73,7 +73,7 @@ def __init__(

async def execute(
self, params: MoveToMaintenancePositionParams
) -> SuccessData[MoveToMaintenancePositionResult, None]:
) -> SuccessData[MoveToMaintenancePositionResult]:
"""Move the requested mount to a maintenance deck slot."""
ot3_api = ensure_ot3_hardware(
self._hardware_api,
Expand Down
4 changes: 1 addition & 3 deletions api/src/opentrons/protocol_engine/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ class BaseCommand(
# Our _ImplementationCls must return public result data that can fit
# in our `result` field:
_ResultT,
# But we don't care (here) what kind of private result data it returns:
object,
],
DefinedErrorData[
# Our _ImplementationCls must return public error data that can fit
Expand All @@ -247,7 +245,7 @@ class BaseCommand(
_ExecuteReturnT_co = TypeVar(
"_ExecuteReturnT_co",
bound=Union[
SuccessData[BaseModel, object],
SuccessData[BaseModel],
DefinedErrorData[ErrorOccurrence],
],
covariant=True,
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/commands/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class CommentResult(BaseModel):


class CommentImplementation(
AbstractCommandImpl[CommentParams, SuccessData[CommentResult, None]]
AbstractCommandImpl[CommentParams, SuccessData[CommentResult]]
):
"""Comment command implementation."""

def __init__(self, **kwargs: object) -> None:
pass

async def execute(self, params: CommentParams) -> SuccessData[CommentResult, None]:
async def execute(self, params: CommentParams) -> SuccessData[CommentResult]:
"""No operation taken other than capturing message in command."""
return SuccessData(
public=CommentResult(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ConfigureForVolumeResult(BaseModel):
class ConfigureForVolumeImplementation(
AbstractCommandImpl[
ConfigureForVolumeParams,
SuccessData[ConfigureForVolumeResult, None],
SuccessData[ConfigureForVolumeResult],
]
):
"""Configure for volume command implementation."""
Expand All @@ -53,7 +53,7 @@ def __init__(self, equipment: EquipmentHandler, **kwargs: object) -> None:

async def execute(
self, params: ConfigureForVolumeParams
) -> SuccessData[ConfigureForVolumeResult, None]:
) -> SuccessData[ConfigureForVolumeResult]:
"""Check that requested pipette can be configured for the given volume."""
pipette_result = await self._equipment.configure_for_volume(
pipette_id=params.pipetteId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ConfigureNozzleLayoutResult(BaseModel):
class ConfigureNozzleLayoutImplementation(
AbstractCommandImpl[
ConfigureNozzleLayoutParams,
SuccessData[ConfigureNozzleLayoutResult, None],
SuccessData[ConfigureNozzleLayoutResult],
]
):
"""Configure nozzle layout command implementation."""
Expand All @@ -59,7 +59,7 @@ def __init__(

async def execute(
self, params: ConfigureNozzleLayoutParams
) -> SuccessData[ConfigureNozzleLayoutResult, None]:
) -> SuccessData[ConfigureNozzleLayoutResult]:
"""Check that requested pipette can support the requested nozzle layout."""
primary_nozzle = params.configurationParams.dict().get("primaryNozzle")
front_right_nozzle = params.configurationParams.dict().get("frontRightNozzle")
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/commands/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class Config:


class CustomImplementation(
AbstractCommandImpl[CustomParams, SuccessData[CustomResult, None]]
AbstractCommandImpl[CustomParams, SuccessData[CustomResult]]
):
"""Custom command implementation."""

# TODO(mm, 2022-11-09): figure out how a plugin can specify a custom command
# implementation. For now, always no-op, so we can use custom commands as containers
# for legacy RPC (pre-ProtocolEngine) payloads.
async def execute(self, params: CustomParams) -> SuccessData[CustomResult, None]:
async def execute(self, params: CustomParams) -> SuccessData[CustomResult]:
"""A custom command does nothing when executed directly."""
return SuccessData(
public=CustomResult.construct(),
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/dispense.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DispenseResult(BaseLiquidHandlingResult, DestinationPositionResult):


_ExecuteReturn = Union[
SuccessData[DispenseResult, None],
SuccessData[DispenseResult],
DefinedErrorData[OverpressureError],
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DispenseInPlaceResult(BaseLiquidHandlingResult):


_ExecuteReturn = Union[
SuccessData[DispenseInPlaceResult, None],
SuccessData[DispenseInPlaceResult],
DefinedErrorData[OverpressureError],
]

Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/drop_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DropTipResult(DestinationPositionResult):


_ExecuteReturn = (
SuccessData[DropTipResult, None] | DefinedErrorData[TipPhysicallyAttachedError]
SuccessData[DropTipResult] | DefinedErrorData[TipPhysicallyAttachedError]
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class DropTipInPlaceResult(BaseModel):


_ExecuteReturn = (
SuccessData[DropTipInPlaceResult, None]
| DefinedErrorData[TipPhysicallyAttachedError]
SuccessData[DropTipInPlaceResult] | DefinedErrorData[TipPhysicallyAttachedError]
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GetTipPresenceResult(BaseModel):


class GetTipPresenceImplementation(
AbstractCommandImpl[GetTipPresenceParams, SuccessData[GetTipPresenceResult, None]]
AbstractCommandImpl[GetTipPresenceParams, SuccessData[GetTipPresenceResult]]
):
"""GetTipPresence command implementation."""

Expand All @@ -51,7 +51,7 @@ def __init__(

async def execute(
self, params: GetTipPresenceParams
) -> SuccessData[GetTipPresenceResult, None]:
) -> SuccessData[GetTipPresenceResult]:
"""Verify if tip presence is as expected for the requested pipette."""
pipette_id = params.pipetteId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class CloseLabwareLatchResult(BaseModel):


class CloseLabwareLatchImpl(
AbstractCommandImpl[
CloseLabwareLatchParams, SuccessData[CloseLabwareLatchResult, None]
]
AbstractCommandImpl[CloseLabwareLatchParams, SuccessData[CloseLabwareLatchResult]]
):
"""Execution implementation of a Heater-Shaker's close labware latch command."""

Expand All @@ -44,7 +42,7 @@ def __init__(

async def execute(
self, params: CloseLabwareLatchParams
) -> SuccessData[CloseLabwareLatchResult, None]:
) -> SuccessData[CloseLabwareLatchResult]:
"""Close a Heater-Shaker's labware latch."""
# Allow propagation of ModuleNotLoadedError and WrongModuleTypeError.
hs_module_substate = self._state_view.modules.get_heater_shaker_module_substate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class DeactivateHeaterResult(BaseModel):


class DeactivateHeaterImpl(
AbstractCommandImpl[
DeactivateHeaterParams, SuccessData[DeactivateHeaterResult, None]
]
AbstractCommandImpl[DeactivateHeaterParams, SuccessData[DeactivateHeaterResult]]
):
"""Execution implementation of a Heater-Shaker's deactivate heater command."""

Expand All @@ -44,7 +42,7 @@ def __init__(

async def execute(
self, params: DeactivateHeaterParams
) -> SuccessData[DeactivateHeaterResult, None]:
) -> SuccessData[DeactivateHeaterResult]:
"""Unset a Heater-Shaker's target temperature."""
hs_module_substate = self._state_view.modules.get_heater_shaker_module_substate(
module_id=params.moduleId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class DeactivateShakerResult(BaseModel):


class DeactivateShakerImpl(
AbstractCommandImpl[
DeactivateShakerParams, SuccessData[DeactivateShakerResult, None]
]
AbstractCommandImpl[DeactivateShakerParams, SuccessData[DeactivateShakerResult]]
):
"""Execution implementation of a Heater-Shaker's deactivate shaker command."""

Expand All @@ -43,7 +41,7 @@ def __init__(

async def execute(
self, params: DeactivateShakerParams
) -> SuccessData[DeactivateShakerResult, None]:
) -> SuccessData[DeactivateShakerResult]:
"""Deactivate shaker for a Heater-Shaker."""
# Allow propagation of ModuleNotLoadedError and WrongModuleTypeError.
hs_module_substate = self._state_view.modules.get_heater_shaker_module_substate(
Expand Down
Loading

0 comments on commit 93b408d

Please sign in to comment.