1111from typing import Generator
1212from typing import Iterable
1313
14- from _pytask .collect_utils import depends_on
1514from _pytask .collect_utils import parse_dependencies_from_task_function
16- from _pytask .collect_utils import parse_nodes
1715from _pytask .collect_utils import parse_products_from_task_function
1816from _pytask .config import hookimpl
1917from _pytask .config import IS_FILE_SYSTEM_CASE_SENSITIVE
2220from _pytask .console import format_task_id
2321from _pytask .exceptions import CollectionError
2422from _pytask .mark_utils import has_mark
23+ from _pytask .models import NodeInfo
2524from _pytask .nodes import FilePathNode
25+ from _pytask .nodes import MetaNode
2626from _pytask .nodes import PythonNode
2727from _pytask .nodes import Task
2828from _pytask .outcomes import CollectionOutcome
@@ -169,13 +169,7 @@ def pytask_collect_task(
169169
170170 """
171171 if (name .startswith ("task_" ) or has_mark (obj , "task" )) and callable (obj ):
172- if has_mark (obj , "depends_on" ):
173- nodes = parse_nodes (session , path , name , obj , depends_on )
174- dependencies = {"depends_on" : nodes }
175- else :
176- dependencies = parse_dependencies_from_task_function (
177- session , path , name , obj
178- )
172+ dependencies = parse_dependencies_from_task_function (session , path , name , obj )
179173
180174 products = parse_products_from_task_function (session , path , name , obj )
181175
@@ -210,9 +204,7 @@ def pytask_collect_task(
210204
211205
212206@hookimpl (trylast = True )
213- def pytask_collect_node (
214- session : Session , path : Path , node : str | Path
215- ) -> FilePathNode | PythonNode :
207+ def pytask_collect_node (session : Session , path : Path , node_info : NodeInfo ) -> MetaNode :
216208 """Collect a node of a task as a :class:`pytask.nodes.FilePathNode`.
217209
218210 Strings are assumed to be paths. This might be a strict assumption, but since this
@@ -222,17 +214,18 @@ def pytask_collect_node(
222214 ``trylast=True`` might be necessary if other plugins try to parse strings themselves
223215 like a plugin for downloading files which depends on URLs given as strings.
224216
225- Parameters
226- ----------
227- session : _pytask.session.Session
228- The session.
229- path : Union[str, pathlib.Path]
230- The path to file where the task and node are specified.
231- node : Union[str, pathlib.Path]
232- The value of the node which can be a str, a path or anything which cannot be
233- handled by this function.
234-
235217 """
218+ node = node_info .value
219+
220+ if isinstance (node , PythonNode ):
221+ if not node .name :
222+ suffix = "-" + "-" .join (map (str , node_info .path )) if node_info .path else ""
223+ node .name = node_info .arg_name + suffix
224+ return node
225+
226+ if isinstance (node , MetaNode ):
227+ return node
228+
236229 if isinstance (node , Path ):
237230 if not node .is_absolute ():
238231 node = path .parent .joinpath (node )
@@ -251,7 +244,10 @@ def pytask_collect_node(
251244 raise ValueError (_TEMPLATE_ERROR .format (node , case_sensitive_path ))
252245
253246 return FilePathNode .from_path (node )
254- return PythonNode (value = node )
247+
248+ suffix = "-" + "-" .join (map (str , node_info .path )) if node_info .path else ""
249+ node_name = node_info .arg_name + suffix
250+ return PythonNode (value = node , name = node_name )
255251
256252
257253def _not_ignored_paths (
@@ -263,18 +259,6 @@ def _not_ignored_paths(
263259 directories, all subsequent files and folders are considered, but one level after
264260 another, so that files of ignored folders are not checked.
265261
266- Parameters
267- ----------
268- paths : Iterable[pathlib.Path]
269- List of paths from which tasks are collected.
270- session : _pytask.session.Session
271- The session.
272-
273- Yields
274- ------
275- path : pathlib.Path
276- A path which is not ignored.
277-
278262 """
279263 for path in paths :
280264 if not session .hook .pytask_ignore_collect (path = path , config = session .config ):
@@ -287,11 +271,7 @@ def _not_ignored_paths(
287271
288272@hookimpl (trylast = True )
289273def pytask_collect_modify_tasks (tasks : list [Task ]) -> None :
290- """Given all tasks, assign a short uniquely identifiable name to each task.
291-
292- The shorter ids are necessary to display
293-
294- """
274+ """Given all tasks, assign a short uniquely identifiable name to each task."""
295275 id_to_short_id = _find_shortest_uniquely_identifiable_name_for_tasks (tasks )
296276 for task in tasks :
297277 short_id = id_to_short_id [task .name ]
0 commit comments