Skip to content

Commit

Permalink
fix lint and typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwierenga committed Nov 21, 2023
1 parent bda8d1d commit 149c60a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pylabrobot/liquid_handling/backends/hamilton/STAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ async def aspirate(
minimum_traverse_height_at_beginning_of_a_command: int = 2450,
min_z_endpos: int = 2450,

hamilton_liquid_classes: List[HamiltonLiquidClass] = None
hamilton_liquid_classes: Optional[List[Optional[HamiltonLiquidClass]]] = None
):
""" Aspirate liquid from the specified channels.
Expand Down Expand Up @@ -1666,7 +1666,7 @@ async def dispense(
min_z_endpos: int = 2450,
side_touch_off_distance: int = 0,

hamilton_liquid_classes: List[HamiltonLiquidClass] = None
hamilton_liquid_classes: Optional[List[Optional[HamiltonLiquidClass]]] = None
):
""" Dispense liquid from the specified channels.
Expand Down
10 changes: 6 additions & 4 deletions pylabrobot/liquid_handling/backends/hamilton/vantage.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ async def aspirate(
is_core=False,
is_tip=True,
has_filter=op.tip.has_filter,
liquid=op.liquid or Liquid.WATER,
liquid=op.liquids[-1][0] or Liquid.WATER,
jet=False, # for aspiration
empty=False # for aspiration
) for op in ops]
Expand Down Expand Up @@ -665,7 +665,7 @@ def should_empty(op):
is_core=False,
is_tip=True,
has_filter=op.tip.has_filter,
liquid=op.liquid or Liquid.WATER,
liquid=op.liquids[-1][0] or Liquid.WATER,
jet=jet,
empty=empty
) for jet, empty, op in zip(jet, empty, ops)]
Expand Down Expand Up @@ -823,7 +823,8 @@ async def aspirate96(
is_core=True,
is_tip=True,
has_filter=tip.has_filter,
liquid=aspiration.liquid or Liquid.WATER,
# first part of tuple in last liquid of first well
liquid=aspiration.liquids[0][-1][0] or Liquid.WATER,
jet=jet,
empty=empty
)
Expand Down Expand Up @@ -930,7 +931,8 @@ async def dispense96(
is_core=True,
is_tip=True,
has_filter=tip.has_filter,
liquid=dispense.liquid or Liquid.WATER,
# first part of tuple in last liquid of first well
liquid=dispense.liquids[0][-1][0] or Liquid.WATER,
jet=jet,
empty=empty
)
Expand Down
4 changes: 2 additions & 2 deletions pylabrobot/liquid_handling/backends/tecan/EVO.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async def aspirate(
tecan_liquid_classes = [
get_liquid_class(
target_volume=op.volume,
liquid_class=op.liquid or Liquid.WATER,
liquid_class=op.liquids[-1][0] or Liquid.WATER,
tip_type=op.tip.tip_type
) if isinstance(op.tip, TecanTip) else None for op in ops]

Expand Down Expand Up @@ -390,7 +390,7 @@ async def dispense(
tecan_liquid_classes = [
get_liquid_class(
target_volume=op.volume,
liquid_class=op.liquid or Liquid.WATER,
liquid_class=op.liquids[-1][0] or Liquid.WATER,
tip_type=op.tip.tip_type
) if isinstance(op.tip, TecanTip) else None for op in ops]

Expand Down
9 changes: 5 additions & 4 deletions pylabrobot/liquid_handling/liquid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numbers
import threading
import time
from typing import Any, Callable, Dict, Union, Optional, List, Sequence, Set
from typing import Any, Callable, Dict, Union, Optional, List, Sequence, Set, Tuple
import warnings

from pylabrobot.machine import MachineFrontend, need_setup_finished
Expand All @@ -32,6 +32,7 @@
does_tip_tracking,
does_volume_tracking
)
from pylabrobot.resources.liquid import Liquid
from pylabrobot.resources.errors import NoTipError
from pylabrobot.utils.list import expand

Expand Down Expand Up @@ -652,7 +653,7 @@ async def aspirate(
assert len(vols) == len(offsets) == len(flow_rates) == len(liquid_height)

# liquid(s) for each channel. If volume tracking is disabled, use None as the liquid.
liquids = []
liquids: List[List[Tuple[Optional[Liquid], float]]] = []
for r, vol in zip(resources, vols):
if r.tracker.is_disabled or not does_volume_tracking():
liquids.append([(None, vol)])
Expand Down Expand Up @@ -1043,7 +1044,7 @@ async def aspirate_plate(
raise ValueError("Aspirating from plate with lid")

# liquid(s) for each channel. If volume tracking is disabled, use None as the liquid.
liquids = []
liquids: List[List[Tuple[Optional[Liquid], float]]] = []
for w in plate.get_all_items():
if w.tracker.is_disabled or not does_volume_tracking():
liquids.append([(None, volume)])
Expand Down Expand Up @@ -1107,7 +1108,7 @@ async def dispense_plate(
raise ValueError("Dispensing to plate with lid")

# liquid(s) for each channel. If volume tracking is disabled, use None as the liquid.
liquids = []
liquids: List[List[Tuple[Optional[Liquid], float]]] = []
for w in plate.get_all_items():
if w.tracker.is_disabled or not does_volume_tracking():
liquids.append([(None, volume)])
Expand Down
2 changes: 1 addition & 1 deletion pylabrobot/resources/plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Callable, List, Optional, Sequence, Tuple, Union, cast
from typing import List, Optional, Sequence, Tuple, Union, cast


from .liquid import Liquid
Expand Down
2 changes: 1 addition & 1 deletion pylabrobot/resources/volume_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_free_volume(self) -> float:

return self.max_volume - self.get_used_volume()

def get_liquids(self, top_volume: float) -> List[Tuple[Liquid, float]]:
def get_liquids(self, top_volume: float) -> List[Tuple[Optional[Liquid], float]]:
""" Get the liquids in the top `top_volume` uL """

if top_volume > self.get_used_volume():
Expand Down
10 changes: 5 additions & 5 deletions pylabrobot/server/liquid_handling_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import json
import os
import threading
from typing import Any, Coroutine, List, Tuple, Type, TypeVar, Optional, cast
from typing import Any, Coroutine, List, Tuple, Type, Optional, cast

from flask import Blueprint, Flask, request, jsonify, current_app
import werkzeug

from pylabrobot.liquid_handling import LiquidHandler
from pylabrobot.liquid_handling.backends.backend import LiquidHandlerBackend
from pylabrobot.liquid_handling.standard import PipettingOp, Pickup, Aspiration, Dispense, Drop
from pylabrobot.liquid_handling.standard import Pickup, Aspiration, Dispense, Drop
from pylabrobot.resources import Coordinate, Deck, Tip, Liquid
from pylabrobot.serializer import serialize, deserialize
from pylabrobot.serializer import deserialize


lh_api = Blueprint("liquid handling", __name__)
Expand Down Expand Up @@ -191,7 +191,7 @@ async def aspirate():
flow_rate = sc["flow_rate"]
liquid_height = sc["liquid_height"]
blow_out_air_volume = sc["blow_out_air_volume"]
liquids = cast(List[Liquid], deserialize(sc["liquids"]))
liquids = cast(Type[List[Tuple[Liquid | None, float]]], deserialize(sc["liquids"]))
aspirations.append(Aspiration(resource=resource, tip=tip, offset=offset, volume=volume,
flow_rate=flow_rate, liquid_height=liquid_height, blow_out_air_volume=blow_out_air_volume,
liquids=liquids))
Expand Down Expand Up @@ -228,7 +228,7 @@ async def dispense():
flow_rate = sc["flow_rate"]
liquid_height = sc["liquid_height"]
blow_out_air_volume = sc["blow_out_air_volume"]
liquids = cast(Type[Liquid], deserialize(sc["liquids"]))
liquids = cast(Type[List[Tuple[Liquid | None, float]]], deserialize(sc["liquids"]))
dispenses.append(Dispense(resource=resource, tip=tip, offset=offset, volume=volume,
flow_rate=flow_rate, liquid_height=liquid_height, blow_out_air_volume=blow_out_air_volume,
liquids=liquids))
Expand Down

0 comments on commit 149c60a

Please sign in to comment.