Skip to content

Commit a6dfd1e

Browse files
authored
git precommit configuration (#310)
1 parent efd7c85 commit a6dfd1e

File tree

6 files changed

+22
-45
lines changed

6 files changed

+22
-45
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
repos:
2-
- repo: local
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.2.1
34
hooks:
4-
- id: check fix
5-
name: check fix
6-
entry: python -m ruff check --fix pylabrobot --select I
7-
language: system
8-
pass_filenames: false
9-
- id: format
10-
name: format
11-
entry: python -m ruff format pylabrobot
12-
language: system
13-
pass_filenames: false
14-
- id: run-typecheck
15-
name: Run typecheck
16-
entry: python -m mypy pylabrobot --check-untyped-defs
17-
language: system
18-
pass_filenames: false
5+
- id: ruff
6+
args: [ --fix, --select, I ]
7+
files: ^pylabrobot/.*$
8+
- id: ruff-format
9+
files: ^pylabrobot/.*$
10+

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,3 @@
172172
suppress_warnings = ["toc.excluded"]
173173

174174
html_favicon = "_static/favicon.ico"
175-

tools/make_lc.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ def main():
8484
continue
8585

8686
dat = binascii.unhexlify(curve_data[2:])
87-
assert len(dat) % 16 == 0 and not len(dat) == 0, (
88-
"invalid length for " + dat.decode()
89-
)
87+
assert len(dat) % 16 == 0 and not len(dat) == 0, "invalid length for " + dat.decode()
9088

9189
curve: Dict[float, float] = {}
9290

@@ -100,13 +98,12 @@ def main():
10098
if notes != "":
10199
notes = "\n # " + "\n # ".join(notes.splitlines())
102100

103-
if name[0] in {
104-
str(i) for i in range(11)
105-
}: # python doesn't allow numbers as first character
101+
if name[0] in {str(i) for i in range(11)}: # python doesn't allow numbers as first character
106102
name = "_" + name
107103

108104
out_file.write(
109-
textwrap.dedent(f"""\n
105+
textwrap.dedent(
106+
f"""\n
110107
{notes}
111108
mapping[({tip_volume}, {core}, {tip}, {has_filter}, Liquid.{liquid.name}, {jet}, {empty})] = \\
112109
{name} = HamiltonLiquidClass(
@@ -128,7 +125,8 @@ def main():
128125
dispense_settling_time={dispense_settling_time},
129126
dispense_stop_flow_rate={dispense_stop_flow_rate},
130127
dispense_stop_back_volume={dispense_stop_back_volume}
131-
)""")
128+
)"""
129+
)
132130
)
133131

134132
print(name)

tools/make_resources/make_ham_resources.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
def main():
2-
raise NotImplementedError(
3-
"This script is deprecated. Use the new resource definitions."
4-
)
2+
raise NotImplementedError("This script is deprecated. Use the new resource definitions.")
53

64

75
if __name__ == "__main__":

tools/make_resources/ot/make.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
def main(po, to, tro):
24-
2524
p = os.path.join(OT_PATH, "labware", "definitions", "2")
2625
p = os.path.expanduser(p)
2726

@@ -35,9 +34,7 @@ def main(po, to, tro):
3534

3635
try:
3736
# we don't really care about name
38-
resource = load_shared_opentrons_resource(
39-
definition, version=version, name=file
40-
)
37+
resource = load_shared_opentrons_resource(definition, version=version, name=file)
4138
except UnknownResourceType:
4239
print(f"[SKIP] {definition} {version}")
4340
continue

tools/make_resources/tc/make.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import re
32

43
from pylabrobot.resources import Coordinate
@@ -78,9 +77,7 @@ def main(pc, tc, p, tr, tcr):
7877
if all(x == resource_size_x[0] for x in resource_size_x) and all(
7978
y == resource_size_y[0] for y in resource_size_y
8079
):
81-
o.write(
82-
f" sites=create_homogeneous_resources(klass=ResourceHolder, locations=[\n"
83-
)
80+
o.write(f" sites=create_homogeneous_resources(klass=ResourceHolder, locations=[\n")
8481
for l in locations:
8582
o.write(f" {repr(l)},\n")
8683
o.write(f" ],\n")
@@ -174,9 +171,7 @@ def main(pc, tc, p, tr, tcr):
174171
o.write(f" # size_x={size_x},\n")
175172
o.write(f" # size_y={size_y},\n")
176173
o.write(" # size_z=None, # measure the total z height\n")
177-
o.write(
178-
" # nesting_z_height=None, # measure overlap between lid and plate\n"
179-
)
174+
o.write(" # nesting_z_height=None, # measure overlap between lid and plate\n")
180175
o.write(f' # model="{lid_name}",\n')
181176
o.write(" # )\n\n\n")
182177

@@ -226,9 +221,7 @@ def main(pc, tc, p, tr, tcr):
226221
# print a warning, because this parameter is confusing in the file and I don't have
227222
# have a device to test this on. tbc.
228223
tcr.write(' print("WARNING: total_tip_length <= 0.")\n')
229-
tcr.write(
230-
' print("Please get in touch at https://discuss.pylabrobot.org")\n'
231-
)
224+
tcr.write(' print("Please get in touch at https://discuss.pylabrobot.org")\n')
232225
tcr.write(f" return TecanTip(\n")
233226
tcr.write(f" has_filter={has_filter},\n")
234227
tcr.write(f" total_tip_length={total_tip_length},\n")
@@ -259,7 +252,7 @@ def main(pc, tc, p, tr, tcr):
259252
if __name__ == "__main__":
260253
with open("plate_carriers.py", "w") as plate_carriers, open(
261254
"tip_carriers.py", "w"
262-
) as tip_carriers, open("plates.py", "w") as plates, open(
263-
"tip_racks.py", "w"
264-
) as tip_racks, open("tip_creators.py", "w") as tip_creators:
255+
) as tip_carriers, open("plates.py", "w") as plates, open("tip_racks.py", "w") as tip_racks, open(
256+
"tip_creators.py", "w"
257+
) as tip_creators:
265258
main(plate_carriers, tip_carriers, plates, tip_racks, tip_creators)

0 commit comments

Comments
 (0)