Skip to content

Commit 480dad0

Browse files
[pre-commit.ci] pre-commit autoupdate (#25)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <[email protected]>
1 parent 9ae05f5 commit 480dad0

17 files changed

+96
-114
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=100']
@@ -24,28 +24,19 @@ repos:
2424
- id: python-no-log-warn
2525
- id: python-use-type-annotations
2626
- id: text-unicode-replacement-char
27-
- repo: https://github.com/asottile/reorder-python-imports
28-
rev: v3.12.0
29-
hooks:
30-
- id: reorder-python-imports
31-
args: [--py38-plus, --add-import, 'from __future__ import annotations']
3227
- repo: https://github.com/asottile/setup-cfg-fmt
3328
rev: v2.5.0
3429
hooks:
3530
- id: setup-cfg-fmt
36-
- repo: https://github.com/psf/black
37-
rev: 23.9.1
38-
hooks:
39-
- id: black
4031
- repo: https://github.com/astral-sh/ruff-pre-commit
41-
rev: v0.0.292
32+
rev: v0.3.4
4233
hooks:
4334
- id: ruff
35+
- id: ruff-format
4436
- repo: https://github.com/dosisod/refurb
45-
rev: v1.21.0
37+
rev: v2.0.0
4638
hooks:
4739
- id: refurb
48-
args: [--ignore, FURB126]
4940
- repo: https://github.com/executablebooks/mdformat
5041
rev: 0.7.17
5142
hooks:
@@ -55,13 +46,8 @@ repos:
5546
mdformat-black,
5647
]
5748
args: [--wrap, "88"]
58-
- repo: https://github.com/econchick/interrogate
59-
rev: 1.5.0
60-
hooks:
61-
- id: interrogate
62-
args: [-v, --fail-under=40, src]
6349
- repo: https://github.com/pre-commit/mirrors-mypy
64-
rev: 'v1.5.1'
50+
rev: 'v1.9.0'
6551
hooks:
6652
- id: mypy
6753
additional_dependencies: [
@@ -81,7 +67,7 @@ repos:
8167
hooks:
8268
- id: check-manifest
8369
args: [--no-build-isolation]
84-
additional_dependencies: [setuptools-scm, toml]
70+
additional_dependencies: [setuptools-scm, toml, wheel]
8571
- repo: meta
8672
hooks:
8773
- id: check-hooks-apply

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ Use the `serializer` keyword arguments of the `@pytask.mark.julia` decorator wit
213213

214214
```python
215215
@pytask.mark.julia(script="script.jl", serializer="yaml")
216-
def task_example():
217-
...
216+
def task_example(): ...
218217
```
219218

220219
And in your Julia script use
@@ -236,8 +235,7 @@ import json
236235

237236

238237
@pytask.mark.julia(script="script.jl", serializer=json.dumps, suffix=".json")
239-
def task_example():
240-
...
238+
def task_example(): ...
241239
```
242240

243241
### Configuration

pyproject.toml

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
33
build-backend = "setuptools.build_meta"
44

5-
65
[tool.setuptools_scm]
76
write_to = "src/pytask_julia/_version.py"
87

9-
108
[tool.mypy]
119
files = ["src", "tests"]
1210
check_untyped_defs = true
@@ -17,50 +15,31 @@ no_implicit_optional = true
1715
warn_redundant_casts = true
1816
warn_unused_ignores = true
1917

20-
2118
[[tool.mypy.overrides]]
2219
module = "tests.*"
2320
disallow_untyped_defs = false
2421
ignore_errors = true
2522

26-
2723
[tool.ruff]
2824
target-version = "py38"
29-
select = ["ALL"]
3025
fix = true
26+
unsafe-fixes = true
27+
28+
[tool.ruff.lint]
3129
extend-ignore = [
32-
"I", # ignore isort
33-
"TRY", # ignore tryceratops
34-
# Numpy docstyle
35-
"D107",
36-
"D203",
37-
"D212",
38-
"D213",
39-
"D402",
40-
"D413",
41-
"D415",
42-
"D416",
43-
"D417",
44-
# Others.
45-
"D404", # Do not start module docstring with "This".
46-
"RET504", # unnecessary variable assignment before return.
47-
"S101", # raise errors for asserts.
48-
"B905", # strict parameter for zip that was implemented in py310.
49-
"ANN101", # type annotating self
50-
"ANN102", # type annotating cls
51-
"FBT", # flake8-boolean-trap
52-
"EM", # flake8-errmsg
5330
"ANN401", # flake8-annotate typing.Any
54-
"PD", # pandas-vet
55-
"COM812", # trailing comma missing, but black takes care of that
31+
"COM812", # Comply with ruff-format.
32+
"ISC001", # Comply with ruff-format.
5633
]
34+
select = ["ALL"]
5735

36+
[tool.ruff.lint.per-file-ignores]
37+
"tests/*" = ["D", "ANN", "S101"]
5838

59-
[tool.ruff.per-file-ignores]
60-
"tests/*" = ["D", "ANN", "PLR2004", "PLR0913"]
61-
39+
[tool.ruff.lint.isort]
40+
force-single-line = true
6241

63-
[tool.ruff.pydocstyle]
42+
[tool.ruff.lint.pydocstyle]
6443
convention = "numpy"
6544

6645
[tool.pytest.ini_options]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ project_urls =
2525
packages = find:
2626
install_requires =
2727
pluggy>=1.0.0
28-
pytask>=0.4.0
28+
pytask>=0.4.5
2929
python_requires = >=3.8
3030
include_package_data = True
3131
package_dir = =src

src/pytask_julia/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""This module contains the main namespace."""
1+
"""Contains the main namespace."""
2+
23
from __future__ import annotations
34

45
try:

src/pytask_julia/collect.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Collect tasks."""
2+
23
from __future__ import annotations
34

45
import subprocess
@@ -7,26 +8,26 @@
78
from typing import Any
89
from typing import Callable
910

10-
from pytask import has_mark
11-
from pytask import hookimpl
12-
from pytask import is_task_function
1311
from pytask import Mark
1412
from pytask import NodeInfo
15-
from pytask import parse_dependencies_from_task_function
16-
from pytask import parse_products_from_task_function
1713
from pytask import PathNode
1814
from pytask import PTask
1915
from pytask import PythonNode
20-
from pytask import remove_marks
2116
from pytask import Session
2217
from pytask import Task
2318
from pytask import TaskWithoutPath
24-
from pytask_julia.serialization import create_path_to_serialized
19+
from pytask import has_mark
20+
from pytask import hookimpl
21+
from pytask import is_task_function
22+
from pytask import parse_dependencies_from_task_function
23+
from pytask import parse_products_from_task_function
24+
from pytask import remove_marks
25+
2526
from pytask_julia.serialization import SERIALIZERS
27+
from pytask_julia.serialization import create_path_to_serialized
2628
from pytask_julia.shared import julia
2729
from pytask_julia.shared import parse_relative_path
2830

29-
3031
_SEPARATOR: str = "--"
3132
"""str: Separates options for the Julia executable and arguments to the file."""
3233

@@ -62,9 +63,12 @@ def pytask_collect_task(
6263
# Parse the @pytask.mark.julia decorator.
6364
obj, marks = remove_marks(obj, "julia")
6465
if len(marks) > 1:
65-
raise ValueError(
66+
msg = (
6667
f"Task {name!r} has multiple @pytask.mark.julia marks, but only one is "
67-
"allowed.",
68+
"allowed."
69+
)
70+
raise ValueError(
71+
msg,
6872
)
6973

7074
mark = _parse_julia_mark(
@@ -98,10 +102,11 @@ def pytask_collect_task(
98102
)
99103

100104
if not (isinstance(script_node, PathNode) and script_node.path.suffix == ".jl"):
101-
raise ValueError(
105+
msg = (
102106
"The 'script' keyword of the @pytask.mark.julia decorator must point "
103107
f"to Julia file with the .jl suffix, but it is {script_node}."
104108
)
109+
raise ValueError(msg)
105110

106111
options_node = session.hook.pytask_collect_node(
107112
session=session,
@@ -211,8 +216,7 @@ def _parse_julia_mark(
211216
else:
212217
parsed_kwargs["project"] = default_project
213218

214-
mark = Mark("julia", (), parsed_kwargs)
215-
return mark
219+
return Mark("julia", (), parsed_kwargs)
216220

217221

218222
def _parse_project(project: str | Path | None, root: Path) -> list[str]:

src/pytask_julia/config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Configure pytask."""
2+
23
from __future__ import annotations
34

45
from typing import Any
56

67
from pytask import hookimpl
8+
79
from pytask_julia.serialization import SERIALIZERS
810
from pytask_julia.shared import parse_relative_path
911

@@ -14,9 +16,12 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
1416
config["markers"]["julia"] = "Tasks which are executed with Julia."
1517
config["julia_serializer"] = config.get("julia_serializer", "json")
1618
if config["julia_serializer"] not in SERIALIZERS:
17-
raise ValueError(
19+
msg = (
1820
f"'julia_serializer' is {config['julia_serializer']} and not one of "
19-
f"{list(SERIALIZERS)}.",
21+
f"{list(SERIALIZERS)}."
22+
)
23+
raise ValueError(
24+
msg,
2025
)
2126
config["julia_suffix"] = config.get("julia_suffix", "")
2227
config["julia_options"] = _parse_value_or_whitespace_option(
@@ -35,4 +40,5 @@ def _parse_value_or_whitespace_option(value: Any) -> None | list[str]:
3540
return None
3641
if isinstance(value, list):
3742
return list(map(str, value))
38-
raise ValueError(f"'julia_options' is {value} and not a list.")
43+
msg = f"'julia_options' is {value} and not a list."
44+
raise ValueError(msg)

src/pytask_julia/execute.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
"""Execute tasks."""
2+
23
from __future__ import annotations
34

45
import shutil
6+
from typing import TYPE_CHECKING
57
from typing import Any
68

7-
from pytask import get_marks
8-
from pytask import hookimpl
99
from pytask import PPathNode
1010
from pytask import PTask
11-
from pytask import PythonNode
11+
from pytask import get_marks
12+
from pytask import hookimpl
1213
from pytask.tree_util import tree_map
14+
1315
from pytask_julia.serialization import serialize_keyword_arguments
1416
from pytask_julia.shared import julia
1517

18+
if TYPE_CHECKING:
19+
from pathlib import Path
20+
1621

1722
@hookimpl
1823
def pytask_execute_task_setup(task: PTask) -> None:
1924
"""Check whether environment allows executing Julia files."""
2025
marks = get_marks(task, "julia")
2126
if marks:
2227
if shutil.which("julia") is None:
23-
raise RuntimeError(
28+
msg = (
2429
"julia is needed to run Julia scripts, but it is not found on your "
25-
"PATH.",
30+
"PATH."
31+
)
32+
raise RuntimeError(
33+
msg,
2634
)
2735

28-
assert len(marks) == 1
29-
30-
_, _, serializer, suffix, _ = julia(**marks[0].kwargs)
31-
32-
assert serializer
33-
assert suffix is not None
36+
_, _, serializer, _, _ = julia(**marks[0].kwargs)
3437

35-
serialized_node: PythonNode = task.depends_on["_serialized"] # type: ignore[assignment]
36-
serialized_node.value.parent.mkdir(parents=True, exist_ok=True)
38+
serialized_node = task.depends_on["_serialized"]
39+
path: Path = serialized_node.value # type: ignore[attr-defined]
40+
path.parent.mkdir(parents=True, exist_ok=True)
3741
kwargs = collect_keyword_arguments(task)
38-
serialize_keyword_arguments(serializer, serialized_node.value, kwargs)
42+
serialize_keyword_arguments(serializer, path, kwargs)
3943

4044

4145
def collect_keyword_arguments(task: PTask) -> dict[str, Any]:

src/pytask_julia/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Register hook specifications and implementations."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING
56

67
from pytask import hookimpl
8+
79
from pytask_julia import collect
810
from pytask_julia import config
911
from pytask_julia import execute

0 commit comments

Comments
 (0)