From b9d45e8906cbb85b9d29d2d8a46c27c30e39d7fa Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 2 Aug 2022 00:39:09 +0200 Subject: [PATCH 1/2] Fix bug with pytask-latex and pdb flag. --- docs/source/changes.md | 2 ++ src/_pytask/console.py | 2 ++ 2 files changed, 4 insertions(+) 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..e8a326e1 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__) else: return inspect.getsourcelines(function)[1] From 31a743f24f1bc27311d724fada654529a06882a6 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 2 Aug 2022 00:44:06 +0200 Subject: [PATCH 2/2] Fix mypy. --- src/_pytask/console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytask/console.py b/src/_pytask/console.py index e8a326e1..df8ce211 100644 --- a/src/_pytask/console.py +++ b/src/_pytask/console.py @@ -217,7 +217,7 @@ def _get_source_lines(function: Callable[..., Any]) -> int: if isinstance(function, functools.partial): return _get_source_lines(function.func) elif hasattr(function, "__wrapped__"): - return _get_source_lines(function.__wrapped__) + return _get_source_lines(function.__wrapped__) # type: ignore[attr-defined] else: return inspect.getsourcelines(function)[1]