-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(python): use returncode for python exec #80
base: main
Are you sure you want to change the base?
Conversation
Formats and displays any execeptions when `returncode` is not 0.
May also make sense to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ianhi, thanks a lot for the PR! I like it. Could you update the docs to add a section similar to the Shell one, into the Python page? And update the main Usage page to reference both 🙂
@@ -77,7 +77,10 @@ def _run_python( | |||
frame._lines = _code_blocks[frame.filename][frame.lineno - 1] # type: ignore[attr-defined,operator] | |||
else: | |||
frame._line = _code_blocks[frame.filename][frame.lineno - 1] # type: ignore[attr-defined,operator] | |||
raise ExecutionError(code_block("python", "".join(trace.format()), **extra)) from error | |||
if returncode not in [None, 0]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if returncode not in [None, 0]: | |
if returncode not in (None, 0): |
After sleeping on it I've realized it might be nice to be able to specify the exception type, rather than returncode. How do you feel about adding a new field like |
Ok, latest push implements that idea. I think I have one more section of docs to update but curious if you prefer this approach. Switching to exception matching for python/pycon (but not pyodide) and |
I have thought about it and I think I'd prefer we stay with |
Formats and displays any exceptions when
returncode
is not 0.This is helpful if you want to demonstrate code that you expect to raise an error. Doubly so when you are running wiht
mkdocs build --strict
Example rendering in mkdocs-material: