Skip to content

Commit 4b1fbb3

Browse files
committed
Fix issue with partialed functions.
1 parent 5fc2b9f commit 4b1fbb3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/_pytask/mark/structures.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import functools
34
import warnings
45
from typing import Any
56
from typing import Callable
@@ -13,7 +14,10 @@
1314

1415

1516
def is_task_function(func: Any) -> bool:
16-
return callable(func) and getattr(func, "__name__", "<lambda>") != "<lambda>"
17+
return (callable(func) and getattr(func, "__name__", "<lambda>") != "<lambda>") or (
18+
isinstance(func, functools.partial)
19+
and getattr(func.func, "__name__", "<lambda>") != "<lambda>"
20+
)
1721

1822

1923
@define(frozen=True)

tests/test_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def func(produces, content):
347347
produces.write_text(content)
348348
349349
task_func = pytask.mark.produces("out.txt")(
350-
pytask.mark.skip(functools.partial(func, content="hello"))
350+
functools.partial(func, content="hello")
351351
)
352352
"""
353353
tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source))
@@ -357,6 +357,7 @@ def func(produces, content):
357357
assert result.exit_code == ExitCode.OK
358358
assert "Collected 1 task." in result.output
359359
assert "1 Succeeded" in result.output
360+
assert tmp_path.joinpath("out.txt").exists()
360361

361362

362363
@pytest.mark.end_to_end

0 commit comments

Comments
 (0)