Skip to content

Commit 120059e

Browse files
committed
Merge remote-tracking branch 'origin/main' into mlin/wdl-1.2-stdlib
2 parents 0ce86ae + d8d73a4 commit 120059e

File tree

7 files changed

+93
-60
lines changed

7 files changed

+93
-60
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ ci_housekeeping: check_check check doc
4343
ci_unit_tests: unit_tests
4444

4545
check:
46-
ruff check --ignore E741 WDL
46+
ruff check WDL
4747
mypy WDL
48-
ruff format --check --line-length 100 WDL
48+
ruff format --check WDL
4949

5050
check_check:
5151
# regression test against pyre/mypy doing nothing (issue #100)
@@ -54,7 +54,7 @@ check_check:
5454
rm WDL/DELETEME_check_check.py
5555

5656
pretty:
57-
ruff format --line-length 100 WDL
57+
ruff format WDL
5858

5959
# build docker image with current source tree, poised to run tests e.g.:
6060
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp miniwdl

WDL/Expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def infer_type(
7979
assert isinstance(child, Base)
8080
errors.try1(
8181
(
82-
lambda child: lambda: child.infer_type(
83-
type_env, stdlib, check_quant, struct_types
82+
lambda child: (
83+
lambda: child.infer_type(type_env, stdlib, check_quant, struct_types)
8484
)
8585
)(child)
8686
)

WDL/Lint.py

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ def _compound_coercion(
209209
if predicates:
210210
return predicates(to_type, from_type)
211211
if not from_type_predicate:
212-
from_type_predicate = lambda ty: not isinstance( # noqa: E731
213-
ty, (base_to_type, Type.Any)
212+
from_type_predicate = lambda ty: (
213+
not isinstance( # noqa: E731
214+
ty, (base_to_type, Type.Any)
215+
)
214216
)
215217
return from_type_predicate(from_type)
216218
return False
@@ -238,13 +240,15 @@ def decl(self, obj: Tree.Decl) -> Any:
238240
obj.type,
239241
obj.expr.type,
240242
(Type.String,),
241-
lambda from_type: not isinstance(
242-
from_type,
243-
(
244-
(Type.Any, Type.String, Type.File, Type.Directory)
245-
if isinstance(_parent_executable(obj), Tree.Task)
246-
else (Type.Any, Type.String)
247-
),
243+
lambda from_type: (
244+
not isinstance(
245+
from_type,
246+
(
247+
(Type.Any, Type.String, Type.File, Type.Directory)
248+
if isinstance(_parent_executable(obj), Tree.Task)
249+
else (Type.Any, Type.String)
250+
),
251+
)
248252
),
249253
):
250254
self.add(obj, "{} {} = :{}:".format(str(obj.type), obj.name, str(obj.expr.type)))
@@ -300,18 +304,20 @@ def expr(self, obj: Expr.Base) -> Any:
300304
F_i,
301305
arg_i.type,
302306
(Type.String,),
303-
lambda from_type: not isinstance(
304-
from_type,
305-
(
307+
lambda from_type: (
308+
not isinstance(
309+
from_type,
306310
(
307-
Type.Any,
308-
Type.String,
309-
Type.File,
310-
Type.Directory,
311-
)
312-
if isinstance(_parent_executable(obj), Tree.Task)
313-
else (Type.Any, Type.String)
314-
),
311+
(
312+
Type.Any,
313+
Type.String,
314+
Type.File,
315+
Type.Directory,
316+
)
317+
if isinstance(_parent_executable(obj), Tree.Task)
318+
else (Type.Any, Type.String)
319+
),
320+
)
315321
),
316322
):
317323
msg = "{} argument of {}() = :{}:".format(
@@ -465,8 +471,10 @@ def decl(self, obj: Tree.Decl) -> Any:
465471
obj.type,
466472
obj.expr.type,
467473
(Type.StructInstance,),
468-
lambda from_type: isinstance(from_type, Type.Any)
469-
or (isinstance(from_type, Type.Map) and from_type.literal_keys is None),
474+
lambda from_type: (
475+
isinstance(from_type, Type.Any)
476+
or (isinstance(from_type, Type.Map) and from_type.literal_keys is None)
477+
),
470478
):
471479
self.add(
472480
obj,
@@ -482,8 +490,10 @@ def call(self, obj: Tree.Call) -> Any:
482490
decl.type,
483491
inp_expr.type,
484492
(Type.StructInstance,),
485-
lambda from_type: isinstance(from_type, Type.Any)
486-
or (isinstance(from_type, Type.Map) and from_type.literal_keys is None),
493+
lambda from_type: (
494+
isinstance(from_type, Type.Any)
495+
or (isinstance(from_type, Type.Map) and from_type.literal_keys is None)
496+
),
487497
):
488498
msg = "input {} {} = :{}: -- struct initializer isn't statically verified".format(
489499
str(decl.type), decl.name, str(inp_expr.type)

WDL/Tree.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ def typecheck(
434434
for _, runtime_expr in self.runtime.items():
435435
errors.try1(
436436
(
437-
lambda runtime_expr: lambda: runtime_expr.infer_type(
438-
type_env, stdlib, check_quant=check_quant, struct_types=struct_types
437+
lambda runtime_expr: (
438+
lambda: runtime_expr.infer_type(
439+
type_env, stdlib, check_quant=check_quant, struct_types=struct_types
440+
)
439441
)
440442
)(runtime_expr)
441443
) # .typecheck()
@@ -644,9 +646,14 @@ def typecheck_input(
644646
decltype = decl.type.copy(optional=True) if decl.expr else decl.type
645647
errors.try1(
646648
(
647-
lambda expr, decltype: lambda: expr.infer_type(
648-
type_env, stdlib, check_quant=check_quant, struct_types=struct_types
649-
).typecheck(decltype)
649+
lambda expr, decltype: (
650+
lambda: expr.infer_type(
651+
type_env,
652+
stdlib,
653+
check_quant=check_quant,
654+
struct_types=struct_types,
655+
).typecheck(decltype)
656+
)
650657
)(expr, decltype)
651658
)
652659
except KeyError:
@@ -1157,11 +1164,13 @@ def typecheck(self, doc: "Document", check_quant: bool) -> None:
11571164
for decl in self.inputs or []:
11581165
errors.try1(
11591166
(
1160-
lambda decl, type_env: lambda: decl.typecheck(
1161-
type_env,
1162-
stdlib,
1163-
check_quant=check_quant,
1164-
struct_types=doc._struct_types,
1167+
lambda decl, type_env: (
1168+
lambda: decl.typecheck(
1169+
type_env,
1170+
stdlib,
1171+
check_quant=check_quant,
1172+
struct_types=doc._struct_types,
1173+
)
11651174
)
11661175
)(decl, self._type_env)
11671176
)
@@ -1482,8 +1491,8 @@ def typecheck(self, check_quant: bool = True) -> None:
14821491
names.add(task.name)
14831492
errors.try1(
14841493
(
1485-
lambda task: lambda: task.typecheck(
1486-
self._struct_types, check_quant=check_quant
1494+
lambda task: (
1495+
lambda: task.typecheck(self._struct_types, check_quant=check_quant)
14871496
)
14881497
)(task)
14891498
)
@@ -1768,11 +1777,13 @@ def _typecheck_workflow_body(
17681777
_translate_struct_mismatch(
17691778
doc,
17701779
(
1771-
lambda child, type_env: lambda: child.typecheck(
1772-
type_env,
1773-
stdlib,
1774-
check_quant=check_quant,
1775-
struct_types=doc._struct_types,
1780+
lambda child, type_env: (
1781+
lambda: child.typecheck(
1782+
type_env,
1783+
stdlib,
1784+
check_quant=check_quant,
1785+
struct_types=doc._struct_types,
1786+
)
17761787
)
17771788
)(child, self._type_env),
17781789
)
@@ -1783,8 +1794,10 @@ def _typecheck_workflow_body(
17831794
_translate_struct_mismatch(
17841795
doc,
17851796
(
1786-
lambda child, type_env: lambda: child.typecheck_input(
1787-
doc._struct_types, type_env, stdlib, check_quant=check_quant
1797+
lambda child, type_env: (
1798+
lambda: child.typecheck_input(
1799+
doc._struct_types, type_env, stdlib, check_quant=check_quant
1800+
)
17881801
)
17891802
)(child, self._type_env),
17901803
)
@@ -1798,8 +1811,10 @@ def _typecheck_workflow_body(
17981811
_translate_struct_mismatch(
17991812
doc,
18001813
(
1801-
lambda child: lambda: _typecheck_workflow_body(
1802-
doc, stdlib, check_quant, child
1814+
lambda child: (
1815+
lambda: _typecheck_workflow_body(
1816+
doc, stdlib, check_quant, child
1817+
)
18031818
)
18041819
)(child),
18051820
)

WDL/runtime/task.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,13 @@ def _eval_task_inputs(
377377
# supplied None to override any default.
378378
input_decls = task.available_inputs
379379
posix_inputs = posix_inputs.filter(
380-
lambda b: not (
381-
isinstance(b.value, Value.Null)
382-
and b.name in input_decls
383-
and input_decls[b.name].expr
384-
and not input_decls[b.name].type.optional
380+
lambda b: (
381+
not (
382+
isinstance(b.value, Value.Null)
383+
and b.name in input_decls
384+
and input_decls[b.name].expr
385+
and not input_decls[b.name].type.optional
386+
)
385387
)
386388
)
387389

WDL/runtime/workflow.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,13 @@ def __init__(
179179
# allow the supplied None to override any default.
180180
input_decls = workflow.available_inputs
181181
self.inputs = self.inputs.filter(
182-
lambda b: not (
183-
isinstance(b.value, Value.Null)
184-
and b.name in input_decls
185-
and input_decls[b.name].expr
186-
and not input_decls[b.name].type.optional
182+
lambda b: (
183+
not (
184+
isinstance(b.value, Value.Null)
185+
and b.name in input_decls
186+
and input_decls[b.name].expr
187+
and not input_decls[b.name].type.optional
188+
)
187189
)
188190
)
189191

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ write_to = "WDL/_version.py"
7272
mypy_path = "${MYPY_CONFIG_FILE_DIR}/stubs"
7373

7474
[tool.ruff]
75+
line-length = 100
7576
exclude = ["WDL/_version.py"]
77+
78+
[tool.ruff.lint]
79+
ignore = ["E741", "E731"]

0 commit comments

Comments
 (0)