-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add no_traceback argument to :okexcept: option of ipython sphinx directive #13751
base: main
Are you sure you want to change the base?
Conversation
19cf189
to
ecace71
Compare
- use local modified ipython_directive to add optional no_traceback argument to :ok_except: which prevents the (sometimes long) traceback from being printed (default is no argument, i.e. the traceback is printed) and enable the @okexcept pseudodecorator so that it can be applied to individual instructions instead of the whole block - use local modified ipython_console_highlighting to enable syntax highlighting of exceptions without a traceback - fix pylint warnings for ipython_directive.py and simplify "".join(["."] * x) to "." * x The "# noqa: E999" after "@okexcept no_traceback" is necessary to prevent flake8-rst from complaining about syntax errors as it interprets the pseudodecorator as a real python decorator. Items 1 and 2 can be reverted if github.com/ipython/ipython/pull/13751 gets merged upstream.
- use local modified ipython_directive to add optional no_traceback argument to :ok_except: which prevents the (sometimes long) traceback from being printed (default is no argument, i.e. the traceback is printed) and enable the @okexcept pseudodecorator so that it can be applied to individual instructions instead of the whole block - use local modified ipython_console_highlighting to enable syntax highlighting of exceptions without a traceback - fix pylint warnings for ipython_directive.py and simplify "".join(["."] * x) to "." * x The "# noqa: E999" after "@okexcept no_traceback" is necessary to prevent flake8-rst from complaining about syntax errors as it interprets the pseudodecorator as a real python decorator. In ipython_directive.py:1106, pylint complains about access to self.content before its definition although it is defined in the base class. That's why I added "# pylint: disable=access-member-before-definition" to make the pre-commit hook pass. Items 1 and 2 can be reverted if github.com/ipython/ipython/pull/13751 gets merged upstream.
- use local modified ipython_directive to add optional no_traceback argument to :ok_except: which prevents the (sometimes long) traceback from being printed (default is no argument, i.e. the traceback is printed) and enable the @okexcept pseudodecorator so that it can be applied to individual instructions instead of the whole block - use local modified ipython_console_highlighting to enable syntax highlighting of exceptions without a traceback - fix pylint warnings for ipython_directive.py and simplify "".join(["."] * x) to "." * x The "# noqa: E999" after "@okexcept no_traceback" is necessary to prevent flake8-rst from complaining about syntax errors as it interprets the pseudodecorator as a real python decorator. In ipython_directive.py:1106, pylint complains about access to self.content before its definition although it is defined in the base class. That's why I added "# pylint: disable=access-member-before-definition" to make the pre-commit hook pass. Items 1 and 2 can be reverted if github.com/ipython/ipython/pull/13751 gets merged upstream.
@Carreau any comment on this? In pandas (and I guess other projects) we've got some very long traceback in our documentation, that it'd be very nice to reduce. It'd be great if you could have a quick look here and let us know if you are happy with this approach, or what would you suggest. Thank you! |
No objections in principle, I just have been struggling to find time to maintain IPython and review PRs. |
…ctive - add optional no_traceback argument to :ok_except: which prevents the (sometimes long) traceback from being printed, default is no argument, i.e. traceback is printed - enable @okexcept pseudodecorator so that it can be applied to individual instructions instead of the whole block - adjust IPythonConsoleLexer so that it formats exceptions without preceding traceback as usual, add tests for this - apply darker to this commit - document the new argument
Matplotlib decided to not publish this document anymore on their site, see matplotlib/sampledoc#26 (comment)
Totally understandable. Let me know if we can be of help. I'm not familiar with ipython code, but had a look at the PR, and changes make sense to me. Thanks! |
no_traceback
argument to:ok_except:
which prevents the (sometimes long) traceback from being printed, default is no argument, i.e. traceback is printed@okexcept
pseudodecorator so that it can be applied to individual instructions instead of the whole blockIPythonConsoleLexer
so that it formats exceptions without preceding traceback as usual, add tests for thisdarker
to this commitSee also #8686, pandas-dev/pandas#47846 and pandas-dev/pandas/#48394.
This demo shows a minimal example.
(TODO: describe@okexcept
in https://matplotlib.org/sampledoc/ipython_directive.html if this PR is goes in)Edit 16.09.22: no need to update
sampledoc
as Matplotlib decided not to publish or maintain this document anymore, see matplotlib/sampledoc#26 (comment)