@@ -286,12 +286,17 @@ def _check_args(
286
286
method : Callable ,
287
287
backend_kwargs : Dict [str , Any ],
288
288
default : Set [str ],
289
+ strictness : Strictness ,
289
290
) -> Set [str ]:
290
291
"""Checks that the arguments to `method` are valid.
291
292
292
293
Args:
293
294
method: Method to check.
294
295
backend_kwargs: Keyword arguments to `method`.
296
+ default: Default arguments to `method`. (Of the abstract backend)
297
+ strictness: Strictness level. If `Strictness.STRICT`, raises an error if there are extra
298
+ arguments. If `Strictness.WARN`, raises a warning. If `Strictness.IGNORE`, logs a debug
299
+ message.
295
300
296
301
Raises:
297
302
TypeError: If the arguments are invalid.
@@ -320,8 +325,6 @@ def _check_args(
320
325
}
321
326
non_default = {arg for arg , param in args .items () if param .default == inspect .Parameter .empty }
322
327
323
- strictness = get_strictness ()
324
-
325
328
backend_kws = set (backend_kwargs .keys ())
326
329
327
330
missing = non_default - backend_kws
@@ -441,6 +444,7 @@ async def pick_up_tips(
441
444
self .backend .pick_up_tips ,
442
445
backend_kwargs ,
443
446
default = {"ops" , "use_channels" },
447
+ strictness = get_strictness (),
444
448
)
445
449
for extra in extras :
446
450
del backend_kwargs [extra ]
@@ -572,6 +576,7 @@ async def drop_tips(
572
576
self .backend .drop_tips ,
573
577
backend_kwargs ,
574
578
default = {"ops" , "use_channels" },
579
+ strictness = get_strictness (),
575
580
)
576
581
for extra in extras :
577
582
del backend_kwargs [extra ]
@@ -902,6 +907,7 @@ async def aspirate(
902
907
self .backend .aspirate ,
903
908
backend_kwargs ,
904
909
default = {"ops" , "use_channels" },
910
+ strictness = get_strictness (),
905
911
)
906
912
for extra in extras :
907
913
del backend_kwargs [extra ]
@@ -1097,6 +1103,7 @@ async def dispense(
1097
1103
self .backend .dispense ,
1098
1104
backend_kwargs ,
1099
1105
default = {"ops" , "use_channels" },
1106
+ strictness = get_strictness (),
1100
1107
)
1101
1108
for extra in extras :
1102
1109
del backend_kwargs [extra ]
@@ -1265,7 +1272,9 @@ async def pick_up_tips96(
1265
1272
if not tip_rack .num_items == 96 :
1266
1273
raise ValueError ("Tip rack must have 96 tips" )
1267
1274
1268
- extras = self ._check_args (self .backend .pick_up_tips96 , backend_kwargs , default = {"pickup" })
1275
+ extras = self ._check_args (
1276
+ self .backend .pick_up_tips96 , backend_kwargs , default = {"pickup" }, strictness = get_strictness ()
1277
+ )
1269
1278
for extra in extras :
1270
1279
del backend_kwargs [extra ]
1271
1280
@@ -1337,7 +1346,9 @@ async def drop_tips96(
1337
1346
if isinstance (resource , TipRack ) and not resource .num_items == 96 :
1338
1347
raise ValueError ("Tip rack must have 96 tips" )
1339
1348
1340
- extras = self ._check_args (self .backend .drop_tips96 , backend_kwargs , default = {"drop" })
1349
+ extras = self ._check_args (
1350
+ self .backend .drop_tips96 , backend_kwargs , default = {"drop" }, strictness = get_strictness ()
1351
+ )
1341
1352
for extra in extras :
1342
1353
del backend_kwargs [extra ]
1343
1354
@@ -1489,7 +1500,9 @@ async def aspirate96(
1489
1500
):
1490
1501
raise TypeError (f"Resource must be a Plate, Container, or list of Wells, got { resource } " )
1491
1502
1492
- extras = self ._check_args (self .backend .aspirate96 , backend_kwargs , default = {"aspiration" })
1503
+ extras = self ._check_args (
1504
+ self .backend .aspirate96 , backend_kwargs , default = {"aspiration" }, strictness = get_strictness ()
1505
+ )
1493
1506
for extra in extras :
1494
1507
del backend_kwargs [extra ]
1495
1508
@@ -1634,7 +1647,9 @@ async def dispense96(
1634
1647
):
1635
1648
raise TypeError (f"Resource must be a Plate, Container, or list of Wells, got { resource } " )
1636
1649
1637
- extras = self ._check_args (self .backend .dispense96 , backend_kwargs , default = {"dispense" })
1650
+ extras = self ._check_args (
1651
+ self .backend .dispense96 , backend_kwargs , default = {"dispense" }, strictness = get_strictness ()
1652
+ )
1638
1653
for extra in extras :
1639
1654
del backend_kwargs [extra ]
1640
1655
@@ -1790,7 +1805,9 @@ async def pick_up_resource(
1790
1805
direction = direction ,
1791
1806
)
1792
1807
1793
- extras = self ._check_args (self .backend .pick_up_resource , backend_kwargs , default = {"pickup" })
1808
+ extras = self ._check_args (
1809
+ self .backend .pick_up_resource , backend_kwargs , default = {"pickup" }, strictness = get_strictness ()
1810
+ )
1794
1811
for extra in extras :
1795
1812
del backend_kwargs [extra ]
1796
1813
@@ -2011,22 +2028,38 @@ async def move_resource(
2011
2028
if put_direction is not None :
2012
2029
raise NotImplementedError ("put_direction is deprecated, use drop_direction instead" )
2013
2030
2031
+ extra = self ._check_args (
2032
+ self .backend .pick_up_resource ,
2033
+ backend_kwargs ,
2034
+ default = {"pickup" },
2035
+ strictness = Strictness .IGNORE ,
2036
+ )
2037
+ pickup_kwargs = {k : v for k , v in backend_kwargs .items () if k not in extra }
2038
+
2014
2039
await self .pick_up_resource (
2015
2040
resource = resource ,
2016
2041
offset = pickup_offset ,
2017
2042
pickup_distance_from_top = pickup_distance_from_top ,
2018
2043
direction = pickup_direction ,
2019
- ** backend_kwargs ,
2044
+ ** pickup_kwargs ,
2020
2045
)
2021
2046
2022
2047
for intermediate_location in intermediate_locations or []:
2023
2048
await self .move_picked_up_resource (to = intermediate_location )
2024
2049
2050
+ extra = self ._check_args (
2051
+ self .backend .drop_resource ,
2052
+ backend_kwargs ,
2053
+ default = {"drop" },
2054
+ strictness = Strictness .IGNORE ,
2055
+ )
2056
+ drop_kwargs = {k : v for k , v in backend_kwargs .items () if k not in extra }
2057
+
2025
2058
await self .drop_resource (
2026
2059
destination = to ,
2027
2060
offset = destination_offset ,
2028
2061
direction = drop_direction ,
2029
- ** backend_kwargs ,
2062
+ ** drop_kwargs ,
2030
2063
)
2031
2064
2032
2065
async def move_lid (
0 commit comments