Skip to content

Commit a404317

Browse files
[pre-commit.ci] pre-commit autoupdate (#36)
1 parent 73139b7 commit a404317

File tree

8 files changed

+21
-12
lines changed

8 files changed

+21
-12
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: debug-statements
1010
- id: end-of-file-fixer
1111
- repo: https://github.com/pre-commit/pygrep-hooks
12-
rev: v1.9.0
12+
rev: v1.10.0
1313
hooks:
1414
- id: python-check-blanket-noqa
1515
- id: python-check-mock-methods
@@ -36,11 +36,11 @@ repos:
3636
hooks:
3737
- id: black
3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: v0.0.215
39+
rev: v0.0.223
4040
hooks:
4141
- id: ruff
4242
- repo: https://github.com/dosisod/refurb
43-
rev: v1.9.1
43+
rev: v1.10.0
4444
hooks:
4545
- id: refurb
4646
args: [--ignore, FURB126]

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ 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

src/pytask_r/collect.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pytask import Task
1919
from pytask_r.serialization import SERIALIZERS
2020
from pytask_r.shared import r
21+
from pytask_r.shared import R_SCRIPT_KEY
2122

2223

2324
def run_r_script(script: Path, options: list[str], serialized: Path) -> None:
@@ -78,14 +79,14 @@ def pytask_collect_task(
7879
)
7980

8081
if isinstance(task.depends_on, dict):
81-
task.depends_on["__script"] = script_node
82+
task.depends_on[R_SCRIPT_KEY] = script_node
8283
task.attributes["r_keep_dict"] = True
8384
else:
84-
task.depends_on = {0: task.depends_on, "__script": script_node}
85+
task.depends_on = {0: task.depends_on, R_SCRIPT_KEY: script_node}
8586
task.attributes["r_keep_dict"] = False
8687

8788
task.function = functools.partial(
88-
task.function, script=task.depends_on["__script"].path, options=options
89+
task.function, script=task.depends_on[R_SCRIPT_KEY].path, options=options
8990
)
9091

9192
return task

src/pytask_r/execute.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pytask_r.serialization import create_path_to_serialized
1313
from pytask_r.serialization import serialize_keyword_arguments
1414
from pytask_r.shared import r
15+
from pytask_r.shared import R_SCRIPT_KEY
1516

1617

1718
@hookimpl
@@ -44,13 +45,16 @@ def collect_keyword_arguments(task: Task) -> dict[str, Any]:
4445
kwargs = dict(task.kwargs)
4546
task.kwargs = {}
4647

47-
if len(task.depends_on) == 1 and "__script" in task.depends_on:
48+
if len(task.depends_on) == 1 and R_SCRIPT_KEY in task.depends_on:
4849
pass
49-
elif not task.attributes["r_keep_dict"] and len(task.depends_on) == 2:
50+
elif (
51+
not task.attributes["r_keep_dict"]
52+
and len(task.depends_on) == 2 # noqa: PLR2004
53+
):
5054
kwargs["depends_on"] = str(task.depends_on[0].value)
5155
else:
5256
kwargs["depends_on"] = tree_map(lambda x: str(x.value), task.depends_on)
53-
kwargs["depends_on"].pop("__script")
57+
kwargs["depends_on"].pop(R_SCRIPT_KEY)
5458

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

src/pytask_r/parametrize.py

+1-1
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[Any, Any]) -> None:
1212
"""Attach parametrized r arguments to the function with a marker."""
13-
if callable(obj) and "r" in kwargs:
13+
if callable(obj) and "r" in kwargs: # noqa: PLR2004
1414
pytask.mark.r(**kwargs.pop("r"))(obj)

src/pytask_r/shared.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from typing import Sequence
99

1010

11+
R_SCRIPT_KEY = "__script"
12+
13+
1114
def r(
1215
*,
1316
script: str | Path,

tests/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
def test_marker_is_configured(tmp_path):
99
session = main({"paths": tmp_path})
1010

11-
assert "r" in session.config["markers"]
11+
assert "r" in session.config["markers"] # noqa: PLR2004

tests/test_execute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,4 @@ def task_run_r_script():
256256
result = runner.invoke(cli, [tmp_path.as_posix()])
257257

258258
assert result.exit_code == ExitCode.COLLECTION_FAILED
259-
assert "has multiple @pytask.mark.r marks" in result.output
259+
assert "has multiple @pytask.mark.r marks" in result.output # noqa: PLR2004

0 commit comments

Comments
 (0)