diff --git a/docs/source/changes.md b/docs/source/changes.md index a1f05cd1..9ca18750 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -11,6 +11,8 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and - {pull}`289` shortens the task ids when using `pytask collect`. Fixes {issue}`286`. - {pull}`290` implements a dry-run with `pytask --dry-run` to see which tasks would be executed. +- {pull}`296` fixes a bug where the source code of wrapped function could not be + retrieved. ## 0.2.4 - 2022-06-28 diff --git a/src/_pytask/console.py b/src/_pytask/console.py index 2344d927..df8ce211 100644 --- a/src/_pytask/console.py +++ b/src/_pytask/console.py @@ -216,6 +216,8 @@ def _get_source_lines(function: Callable[..., Any]) -> int: """Get the source line number of the function.""" if isinstance(function, functools.partial): return _get_source_lines(function.func) + elif hasattr(function, "__wrapped__"): + return _get_source_lines(function.__wrapped__) # type: ignore[attr-defined] else: return inspect.getsourcelines(function)[1]