8000 Add a -q parameter to %rerun magic by MatthewWilkes · Pull Request #11671 · ipython/ipython · GitHub
[go: up one dir, main page]

Skip to content

Add a -q parameter to %rerun magic #11671

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MatthewWilkes
Copy link

This allows the rerun magic to be run in quiet mode, which suppresses
the === Executing: === and === Output: === headings as well as the
text of the cell being re-run. This means that cells that print can
optionally be re-run as part of a larger control structure like a loop
without IPython-specific noise.

@@ -289,8 +289,10 @@ def rerun(self, parameter_s=''):
current command.

-g foo : Repeat the most recent line which contains foo

-q : Quiet mode: do not echo the cell contents back

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change, but could you make it clearer in the help docs that quiet means to suppress the history lines specifically? A user will still see any output from the command, right? "Quiet" usually implies that all regular output will be suppressed (i.e. non-errors) or maybe just lower verbosity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation tone can often be the hardest part of a contribution. I've reworded this, but let me know if it's still not quite right, or feel free to specify wording yourself if you'd like.

with capture_output() as cap:
ip.run_cell("%rerun -q", store_history=True)
nt.assert_equal(ip.user_ns["a"], 12)
nt.assert_not_in("a += 1", cap.stdout)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on the tests!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, nice work on the support functions like capture_output! ;)

This allows the rerun magic to be run in quiet mode, which suppresses
the `=== Executing: ===` and `=== Output: ===` headings as well as the
text of the cell being re-run. This means that cells that print can
optionally be re-run as part of a larger control structure like a loop
without IPython-specific noise.
@MatthewWilkes
Copy link
Author

I'm struggling to fix the sphinx build issue on Py3.7 here. I can't seem to build the docs locally, but I tried adding a newline to the options section as the output suggested to no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0