From 5e2988950736bff2f987c7d19fc2c57cf9e0955b Mon Sep 17 00:00:00 2001
From: Seth Foster <seth@opentrons.com>
Date: Tue, 5 Sep 2023 17:25:11 -0400
Subject: [PATCH] fix arg logic and leq

---
 .../instruments/ot2/pipette_handler.py        | 28 ++++++++++---------
 .../instruments/ot3/pipette_handler.py        |  2 +-
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py b/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py
index 1113b405bd4..1983475914f 100644
--- a/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py
+++ b/api/src/opentrons/hardware_control/instruments/ot2/pipette_handler.py
@@ -595,22 +595,24 @@ def plan_check_dispense(  # type: ignore[no-untyped-def]
         if disp_vol == 0:
             return None
 
-        is_full_dispense = abs(instrument.current_volume - disp_vol) < (
+        is_full_dispense = abs(instrument.current_volume - disp_vol) <= (
             instrument.minimum_volume / 10
         )
-        if not is_full_dispense and push_out:
-            raise CommandPreconditionViolated(
-                message="Cannot push_out on a dispense that does not leave the pipette empty",
-                detail={
-                    "command": "dispense",
-                    "remaining-volume": instrument.current_volume - disp_vol,
-                },
-            )
-        if push_out is None and not is_full_dispense:
-            push_out_ul = instrument.push_out_volume
-        elif push_out and not is_full_dispense:
-            push_out_ul = push_out
+
+        if is_full_dispense:
+            if push_out is None:
+                push_out_ul = instrument.push_out_volume
+            else:
+                push_out_ul = push_out
         else:
+            if push_out is not None and push_out != 0:
+                raise CommandPreconditionViolated(
+                    message="Cannot push_out on a dispense that does not leave the pipette empty",
+                    detail={
+                        "command": "dispense",
+                        "remaining-volume": instrument.current_volume - disp_vol,
+                    },
+                )
             push_out_ul = 0
 
         push_out_dist_mm = push_out_ul / instrument.ul_per_mm(push_out_ul, "blowout")
diff --git a/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py b/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py
index 142ae273087..cf156714a1d 100644
--- a/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py
+++ b/api/src/opentrons/hardware_control/instruments/ot3/pipette_handler.py
@@ -577,7 +577,7 @@ def plan_check_dispense(
 
         # Ensure we don't dispense more than the current volume
         disp_vol = min(instrument.current_volume, disp_vol)
-        is_full_dispense = abs(instrument.current_volume - disp_vol) < (
+        is_full_dispense = abs(instrument.current_volume - disp_vol) <= (
             instrument.minimum_volume / 10
         )