@@ -216,9 +216,13 @@ def _merge_dictionaries(list_of_dicts: list[dict[Any, Any]]) -> dict[Any, Any]:
216
216
return out
217
217
218
218
219
- _ERROR_MULTIPLE_DEPENDENCY_DEFINITIONS = """"Dependencies are defined via \
220
- '@pytask.mark.depends_on' and as default arguments for the argument 'depends_on'. Use \
221
- only one way and not both.
219
+ _ERROR_MULTIPLE_DEPENDENCY_DEFINITIONS = """The task uses multiple ways to define \
220
+ dependencies. Dependencies should be defined with either
221
+
222
+ - '@pytask.mark.depends_on'
223
+ - as default arguments for the argument 'depends_on'
224
+
225
+ Use only one of the two ways.
222
226
223
227
Hint: You do not need to use 'depends_on' since pytask v0.4. Every function argument \
224
228
that is not a product is treated as a dependency. Read more about dependencies in the \
@@ -232,17 +236,18 @@ def parse_dependencies_from_task_function( # noqa: C901
232
236
"""Parse dependencies from task function."""
233
237
has_depends_on_decorator = False
234
238
has_depends_on_argument = False
239
+ dependencies = {}
235
240
236
241
if has_mark (obj , "depends_on" ):
242
+ has_depends_on_decorator = True
237
243
nodes = parse_nodes (session , path , name , obj , depends_on )
238
- return { "depends_on" : nodes }
244
+ dependencies [ "depends_on" ] = nodes
239
245
240
246
task_kwargs = obj .pytask_meta .kwargs if hasattr (obj , "pytask_meta" ) else {}
241
247
signature_defaults = parse_keyword_arguments_from_signature_defaults (obj )
242
248
kwargs = {** signature_defaults , ** task_kwargs }
243
249
kwargs .pop ("produces" , None )
244
250
245
- dependencies = {}
246
251
# Parse products from task decorated with @task and that uses produces.
247
252
if "depends_on" in kwargs :
248
253
has_depends_on_argument = True
@@ -254,7 +259,7 @@ def parse_dependencies_from_task_function( # noqa: C901
254
259
)
255
260
256
261
if has_depends_on_decorator and has_depends_on_argument :
257
- raise NodeNotCollectedError (_ERROR_MULTIPLE_PRODUCT_DEFINITIONS )
262
+ raise NodeNotCollectedError (_ERROR_MULTIPLE_DEPENDENCY_DEFINITIONS )
258
263
259
264
parameters_with_product_annot = _find_args_with_product_annotation (obj )
260
265
parameters_with_node_annot = _find_args_with_node_annotation (obj )
0 commit comments