Skip to content

Commit 42da034

Browse files
authored
Remove internal traceback frames from exceptions raised within pytask. (#204)
1 parent c883667 commit 42da034

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/source/changes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
2121
- :gh:`200` implements the :func:`@pytask.mark.task <_pytask.task.task>` decorator to
2222
mark functions as tasks regardless whether they are prefixed with ``task_`` or not.
2323
- :gh:`201` adds tests for ``_pytask.mark_utils``.
24+
- :gh:`204` removes internal traceback frames from exceptions raised somewhere in
25+
pytask.
2426

2527

2628
0.1.5 - 2022-01-10

src/_pytask/build.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from _pytask.outcomes import ExitCode
1515
from _pytask.pluginmanager import get_plugin_manager
1616
from _pytask.session import Session
17+
from _pytask.traceback import remove_internal_traceback_frames_from_exc_info
18+
from rich.traceback import Traceback
1719

1820

1921
if TYPE_CHECKING:
@@ -78,7 +80,10 @@ def main(config_from_cli: Dict[str, Any]) -> Session:
7880
session.exit_code = ExitCode.FAILED
7981

8082
except Exception:
81-
console.print_exception()
83+
exc_info = sys.exc_info()
84+
exc_info = remove_internal_traceback_frames_from_exc_info(exc_info)
85+
traceback = Traceback.from_exception(*exc_info)
86+
console.print(traceback)
8287
session.exit_code = ExitCode.FAILED
8388

8489
session.hook.pytask_unconfigure(session=session)

0 commit comments

Comments
 (0)