Skip to content
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

Disabled Progress should not start attached Live #1125

Merged
merged 4 commits into from Mar 26, 2021
Merged

Disabled Progress should not start attached Live #1125

merged 4 commits into from Mar 26, 2021

Conversation

JoshKarpel
Copy link
Contributor

@JoshKarpel JoshKarpel commented Mar 21, 2021

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

If you make a Progress that is disabled, it will still display an initial version of itself because it is the renderable of its attached Live, and the Live is started unconditionally in Progress.start. Example:

from rich.progress import Progress

with Progress(disable=True) as progress:
    task = progress.add_task("foobar", total=100)
    progress.update(task, advance=1)

print("done")

Running this produces this output:
image

With this patch, it produces this:
image


I added some tests for this, but they're poking around the internals to do it - let me know if this isn't your preferred style.

@codecov
Copy link

codecov bot commented Mar 21, 2021

Codecov Report

Merging #1125 (34c5620) into master (e08a838) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1125      +/-   ##
==========================================
+ Coverage   99.77%   99.84%   +0.06%     
==========================================
  Files          69       69              
  Lines        6322     6323       +1     
==========================================
+ Hits         6308     6313       +5     
+ Misses         14       10       -4     
Flag Coverage Δ
unittests 99.84% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/progress.py 98.04% <100.00%> (+0.98%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 472ed32...34c5620. Read the comment docs.

@JoshKarpel JoshKarpel marked this pull request as ready for review March 21, 2021 15:39
@willmcgugan
Copy link
Collaborator

Thanks for this. Would you mind also testing the output? i.e. confirm that when disable=True nothing gets written. Just to catch any regression.

@willmcgugan
Copy link
Collaborator

Thanks.

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.

None yet

2 participants