Skip to content

Commit f1cab2e

Browse files
[pre-commit.ci] pre-commit autoupdate (#19)
1 parent 7b755f7 commit f1cab2e

13 files changed

+142
-43
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
args: [--branch, main]
1717
- id: trailing-whitespace
1818
- repo: https://github.com/pre-commit/pygrep-hooks
19-
rev: v1.9.0
19+
rev: v1.10.0
2020
hooks:
2121
- id: python-check-blanket-noqa
2222
- id: python-check-mock-methods
@@ -43,11 +43,11 @@ repos:
4343
hooks:
4444
- id: black
4545
- repo: https://github.com/charliermarsh/ruff-pre-commit
46-
rev: v0.0.215
46+
rev: v0.0.223
4747
hooks:
4848
- id: ruff
4949
- repo: https://github.com/dosisod/refurb
50-
rev: v1.9.1
50+
rev: v1.10.0
5151
hooks:
5252
- id: refurb
5353
args: [--ignore, FURB126]

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ extend-ignore = [
5151
"EM", # flake8-errmsg
5252
"ANN401", # flake8-annotate typing.Any
5353
"PD", # pandas-vet
54+
"COM812", # trailing comma missing, but black takes care of that
5455
]
5556

5657

5758
[tool.ruff.per-file-ignores]
58-
"tests/*" = ["D", "ANN"]
59+
"tests/*" = ["D", "ANN", "PLR2004"]
5960

6061

6162
[tool.ruff.pydocstyle]

src/pytask_julia/collect.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pytask import Task
2020
from pytask_julia.serialization import SERIALIZERS
2121
from pytask_julia.shared import julia
22+
from pytask_julia.shared import JULIA_SCRIPT_KEY
2223
from pytask_julia.shared import parse_relative_path
2324

2425

@@ -27,7 +28,10 @@
2728

2829

2930
def run_jl_script(
30-
script: Path, options: list[str], serialized: Path, project: list[str]
31+
script: Path,
32+
options: list[str],
33+
serialized: Path,
34+
project: list[str],
3135
) -> None:
3236
"""Run a Julia script."""
3337
cmd = ["julia"] + options + project + [_SEPARATOR, str(script), str(serialized)]
@@ -37,7 +41,10 @@ def run_jl_script(
3741

3842
@hookimpl
3943
def pytask_collect_task(
40-
session: Session, path: Path, name: str, obj: Any
44+
session: Session,
45+
path: Path,
46+
name: str,
47+
obj: Any,
4148
) -> Task | None:
4249
"""Collect a task which is a function.
4350
@@ -59,7 +66,7 @@ def pytask_collect_task(
5966
if len(marks) > 1:
6067
raise ValueError(
6168
f"Task {name!r} has multiple @pytask.mark.julia marks, but only one is "
62-
"allowed."
69+
"allowed.",
6370
)
6471

6572
julia_mark = _parse_julia_mark(
@@ -90,21 +97,23 @@ def pytask_collect_task(
9097
)
9198

9299
script_node = session.hook.pytask_collect_node(
93-
session=session, path=path, node=script
100+
session=session,
101+
path=path,
102+
node=script,
94103
)
95104

96105
if isinstance(task.depends_on, dict):
97-
task.depends_on["__script"] = script_node
106+
task.depends_on[JULIA_SCRIPT_KEY] = script_node
98107
task.attributes["julia_keep_dict"] = True
99108
else:
100-
task.depends_on = {0: task.depends_on, "__script": script_node}
109+
task.depends_on = {0: task.depends_on, JULIA_SCRIPT_KEY: script_node}
101110
task.attributes["julia_keep_dict"] = False
102111

103112
parsed_project = _parse_project(project, task.path.parent)
104113

105114
task.function = functools.partial(
106115
task.function,
107-
script=task.depends_on["__script"].path,
116+
script=task.depends_on[JULIA_SCRIPT_KEY].path,
108117
options=options,
109118
project=parsed_project,
110119
)

src/pytask_julia/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
1616
if config["julia_serializer"] not in SERIALIZERS:
1717
raise ValueError(
1818
f"'julia_serializer' is {config['julia_serializer']} and not one of "
19-
f"{list(SERIALIZERS)}."
19+
f"{list(SERIALIZERS)}.",
2020
)
2121
config["julia_suffix"] = config.get("julia_suffix", "")
2222
config["julia_options"] = _parse_value_or_whitespace_option(
23-
config.get("julia_options")
23+
config.get("julia_options"),
2424
)
2525
project = config.get("julia_project")
2626
if project is None:

src/pytask_julia/execute.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pytask_julia.serialization import create_path_to_serialized
1313
from pytask_julia.serialization import serialize_keyword_arguments
1414
from pytask_julia.shared import julia
15+
from pytask_julia.shared import JULIA_SCRIPT_KEY
1516

1617

1718
@hookimpl
@@ -22,7 +23,7 @@ def pytask_execute_task_setup(task: Task) -> None:
2223
if shutil.which("julia") is None:
2324
raise RuntimeError(
2425
"julia is needed to run Julia scripts, but it is not found on your "
25-
"PATH."
26+
"PATH.",
2627
)
2728

2829
assert len(marks) == 1
@@ -45,13 +46,16 @@ def collect_keyword_arguments(task: Task) -> dict[str, Any]:
4546
kwargs = dict(task.kwargs)
4647
task.kwargs = {}
4748

48-
if len(task.depends_on) == 1 and "__script" in task.depends_on:
49+
if len(task.depends_on) == 1 and JULIA_SCRIPT_KEY in task.depends_on:
4950
pass
50-
elif not task.attributes["julia_keep_dict"] and len(task.depends_on) == 2:
51+
elif (
52+
not task.attributes["julia_keep_dict"]
53+
and len(task.depends_on) == 2 # noqa: PLR2004
54+
):
5155
kwargs["depends_on"] = str(task.depends_on[0].value)
5256
else:
5357
kwargs["depends_on"] = tree_map(lambda x: str(x.value), task.depends_on)
54-
kwargs["depends_on"].pop("__script")
58+
kwargs["depends_on"].pop(JULIA_SCRIPT_KEY)
5559

5660
if task.produces:
5761
kwargs["produces"] = tree_map(lambda x: str(x.value), task.produces)

src/pytask_julia/parametrize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
@hookimpl
1111
def pytask_parametrize_kwarg_to_marker(obj: Any, kwargs: dict[str, Any]) -> None:
1212
"""Attach parametrized Julia arguments to the function with a marker."""
13-
if callable(obj) and "julia" in kwargs:
13+
if callable(obj) and "julia" in kwargs: # noqa: PLR2004
1414
pytask.mark.julia(**kwargs.pop("julia"))(obj)

src/pytask_julia/shared.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from typing import Sequence
99

1010

11+
JULIA_SCRIPT_KEY = "__script"
12+
13+
1114
def julia(
1215
script: str | Path,
1316
options: str | Iterable[str] | None = None,

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212

1313
needs_julia = pytest.mark.skipif(
14-
shutil.which("julia") is None, reason="julia needs to be installed."
14+
shutil.which("julia") is None,
15+
reason="julia needs to be installed.",
1516
)
1617

1718

tests/test_collect.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ def test_parse_julia_mark(
8282
):
8383
with expectation:
8484
out = _parse_julia_mark(
85-
mark, default_options, default_serializer, default_suffix, default_project
85+
mark,
86+
default_options,
87+
default_serializer,
88+
default_suffix,
89+
default_project,
8690
)
8791
assert out == expected
8892

tests/test_execute.py

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ def test_pytask_execute_task_setup_missing_julia(monkeypatch):
2323
"""Make sure that the task setup raises errors."""
2424
# Act like julia is installed since we do not test this.
2525
monkeypatch.setattr(
26-
"pytask_julia.execute.shutil.which", lambda x: None # noqa: ARG005
26+
"pytask_julia.execute.shutil.which",
27+
lambda x: None, # noqa: ARG005
2728
)
2829
task = Task(
29-
base_name="example", path=Path(), function=None, markers=[Mark("julia", (), {})]
30+
base_name="example",
31+
path=Path(),
32+
function=None,
33+
markers=[Mark("julia", (), {})],
3034
)
3135
with pytest.raises(RuntimeError, match="julia is needed"):
3236
pytask_execute_task_setup(task)
@@ -37,7 +41,12 @@ def test_pytask_execute_task_setup_missing_julia(monkeypatch):
3741
@parametrize_parse_code_serializer_suffix
3842
@pytest.mark.parametrize("depends_on", ["'in_1.txt'", "['in_1.txt', 'in_2.txt']"])
3943
def test_run_jl_script(
40-
runner, tmp_path, parse_config_code, serializer, suffix, depends_on
44+
runner,
45+
tmp_path,
46+
parse_config_code,
47+
serializer,
48+
suffix,
49+
depends_on,
4150
):
4251
task_source = f"""
4352
import pytask
@@ -75,15 +84,20 @@ def task_run_jl_script():
7584
assert result.exit_code == ExitCode.OK
7685
assert tmp_path.joinpath("out.txt").exists()
7786
assert tmp_path.joinpath(
78-
".pytask", "task_dummy_py_task_run_jl_script" + suffix
87+
".pytask",
88+
"task_dummy_py_task_run_jl_script" + suffix,
7989
).exists()
8090

8191

8292
@needs_julia
8393
@pytest.mark.end_to_end()
8494
@parametrize_parse_code_serializer_suffix
8595
def test_run_jl_script_w_task_decorator(
86-
runner, tmp_path, parse_config_code, serializer, suffix
96+
runner,
97+
tmp_path,
98+
parse_config_code,
99+
serializer,
100+
suffix,
87101
):
88102
task_source = f"""
89103
import pytask
@@ -118,7 +132,11 @@ def run_jl_script():
118132
@pytest.mark.end_to_end()
119133
@parametrize_parse_code_serializer_suffix
120134
def test_raise_error_if_julia_is_not_found(
121-
tmp_path, monkeypatch, parse_config_code, serializer, suffix
135+
tmp_path,
136+
monkeypatch,
137+
parse_config_code,
138+
serializer,
139+
suffix,
122140
):
123141
task_source = f"""
124142
import pytask
@@ -146,7 +164,8 @@ def task_run_jl_script():
146164

147165
# Hide julia if available.
148166
monkeypatch.setattr(
149-
"pytask_julia.execute.shutil.which", lambda x: None # noqa: ARG005
167+
"pytask_julia.execute.shutil.which",
168+
lambda x: None, # noqa: ARG005
150169
)
151170

152171
session = main({"paths": tmp_path})
@@ -159,7 +178,11 @@ def task_run_jl_script():
159178
@pytest.mark.end_to_end()
160179
@parametrize_parse_code_serializer_suffix
161180
def test_run_jl_script_w_wrong_cmd_option(
162-
runner, tmp_path, parse_config_code, serializer, suffix
181+
runner,
182+
tmp_path,
183+
parse_config_code,
184+
serializer,
185+
suffix,
163186
):
164187
task_source = f"""
165188
import pytask
@@ -195,7 +218,12 @@ def task_run_jl_script():
195218
@pytest.mark.parametrize("n_threads", [2, 3])
196219
@parametrize_parse_code_serializer_suffix
197220
def test_check_passing_cmd_line_options(
198-
runner, tmp_path, n_threads, parse_config_code, serializer, suffix
221+
runner,
222+
tmp_path,
223+
n_threads,
224+
parse_config_code,
225+
serializer,
226+
suffix,
199227
):
200228
task_source = f"""
201229
import pytask
@@ -242,7 +270,14 @@ def task_run_jl_script():
242270
)
243271
@pytest.mark.parametrize("path", [ROOT, "relative_from_config"])
244272
def test_run_jl_script_w_environment_in_config(
245-
runner, tmp_path, parse_config_code, serializer, suffix, config_path, value, path
273+
runner,
274+
tmp_path,
275+
parse_config_code,
276+
serializer,
277+
suffix,
278+
config_path,
279+
value,
280+
path,
246281
):
247282
task_source = f"""
248283
import pytask
@@ -279,7 +314,8 @@ def task_run_jl_script():
279314
assert result.exit_code == ExitCode.OK
280315
assert tmp_path.joinpath("out.txt").exists()
281316
assert tmp_path.joinpath(
282-
".pytask", "task_dummy_py_task_run_jl_script" + suffix
317+
".pytask",
318+
"task_dummy_py_task_run_jl_script" + suffix,
283319
).exists()
284320

285321

@@ -291,7 +327,11 @@ def task_run_jl_script():
291327
)
292328
@parametrize_parse_code_serializer_suffix
293329
def test_run_jl_script_w_environment_relative_to_task(
294-
runner, tmp_path, parse_config_code, serializer, suffix
330+
runner,
331+
tmp_path,
332+
parse_config_code,
333+
serializer,
334+
suffix,
295335
):
296336
project_in_task = Path(os.path.relpath(ROOT, tmp_path)).as_posix()
297337

@@ -324,7 +364,8 @@ def task_run_jl_script():
324364
assert result.exit_code == ExitCode.OK
325365
assert tmp_path.joinpath("out.txt").exists()
326366
assert tmp_path.joinpath(
327-
".pytask", "task_dummy_py_task_run_jl_script" + suffix
367+
".pytask",
368+
"task_dummy_py_task_run_jl_script" + suffix,
328369
).exists()
329370

330371

tests/test_normal_execution_w_plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
)
1616
@pytest.mark.parametrize("products", [("out.txt",), ("out_1.txt", "out_2.txt")])
1717
def test_execution_w_varying_dependencies_products(
18-
runner, tmp_path, dependencies, products
18+
runner,
19+
tmp_path,
20+
dependencies,
21+
products,
1922
):
2023
source = f"""
2124
import pytask

0 commit comments

Comments
 (0)