|
1 | 1 | """Collect tasks.""" |
| 2 | + |
2 | 3 | from __future__ import annotations |
3 | 4 |
|
4 | 5 | import subprocess |
|
7 | 8 | from typing import Any |
8 | 9 | from typing import Callable |
9 | 10 |
|
10 | | -from pytask import has_mark |
11 | | -from pytask import hookimpl |
12 | | -from pytask import is_task_function |
13 | 11 | from pytask import Mark |
14 | 12 | from pytask import NodeInfo |
15 | | -from pytask import parse_dependencies_from_task_function |
16 | | -from pytask import parse_products_from_task_function |
17 | 13 | from pytask import PathNode |
18 | 14 | from pytask import PTask |
19 | 15 | from pytask import PythonNode |
20 | | -from pytask import remove_marks |
21 | 16 | from pytask import Session |
22 | 17 | from pytask import Task |
23 | 18 | 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 | + |
25 | 26 | from pytask_julia.serialization import SERIALIZERS |
| 27 | +from pytask_julia.serialization import create_path_to_serialized |
26 | 28 | from pytask_julia.shared import julia |
27 | 29 | from pytask_julia.shared import parse_relative_path |
28 | 30 |
|
29 | | - |
30 | 31 | _SEPARATOR: str = "--" |
31 | 32 | """str: Separates options for the Julia executable and arguments to the file.""" |
32 | 33 |
|
@@ -62,9 +63,12 @@ def pytask_collect_task( |
62 | 63 | # Parse the @pytask.mark.julia decorator. |
63 | 64 | obj, marks = remove_marks(obj, "julia") |
64 | 65 | if len(marks) > 1: |
65 | | - raise ValueError( |
| 66 | + msg = ( |
66 | 67 | f"Task {name!r} has multiple @pytask.mark.julia marks, but only one is " |
67 | | - "allowed.", |
| 68 | + "allowed." |
| 69 | + ) |
| 70 | + raise ValueError( |
| 71 | + msg, |
68 | 72 | ) |
69 | 73 |
|
70 | 74 | mark = _parse_julia_mark( |
@@ -98,10 +102,11 @@ def pytask_collect_task( |
98 | 102 | ) |
99 | 103 |
|
100 | 104 | if not (isinstance(script_node, PathNode) and script_node.path.suffix == ".jl"): |
101 | | - raise ValueError( |
| 105 | + msg = ( |
102 | 106 | "The 'script' keyword of the @pytask.mark.julia decorator must point " |
103 | 107 | f"to Julia file with the .jl suffix, but it is {script_node}." |
104 | 108 | ) |
| 109 | + raise ValueError(msg) |
105 | 110 |
|
106 | 111 | options_node = session.hook.pytask_collect_node( |
107 | 112 | session=session, |
@@ -211,8 +216,7 @@ def _parse_julia_mark( |
211 | 216 | else: |
212 | 217 | parsed_kwargs["project"] = default_project |
213 | 218 |
|
214 | | - mark = Mark("julia", (), parsed_kwargs) |
215 | | - return mark |
| 219 | + return Mark("julia", (), parsed_kwargs) |
216 | 220 |
|
217 | 221 |
|
218 | 222 | def _parse_project(project: str | Path | None, root: Path) -> list[str]: |
|
0 commit comments