Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[codex] Modernize README demos and progress ergonomics#317

Draft
wolph wants to merge 725 commits into
developfrom
harden-issue-tests
Draft

[codex] Modernize README demos and progress ergonomics#317
wolph wants to merge 725 commits into
developfrom
harden-issue-tests

Conversation

@wolph

@wolph wolph commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • refresh the README with animated SVG demos and clearer usage examples for labels, totals, live output, and concurrent bars
  • place the exact demo code directly under each animated SVG so the rendered output and source stay paired
  • render README SVG colors from captured ANSI output so percentage/count colors match the library's real terminal gradient
  • show the multiple-bar demo with independently progressing bars instead of synchronized values
  • simplify the unknown-length demo to use a straightforward range loop
  • remove the extra ergonomics SVG section, generated asset, and obsolete GPG release-verification section
  • keep recent log lines visible in the hero SVG while the progress bar advances
  • use branch-relative README SVG links so the PR branch renders its own demo assets
  • add a repeatable README demo renderer plus tests so documented terminal output stays in sync
  • add CLI rate limiting, tighten unit/progress formatting behavior, and harden stream/logging cleanup around failed bars
  • isolate stream cleanup tests so stale redirected-output state does not leak between cases
  • purge docs/superpowers files from the PR branch history

Validation

  • python scripts/render_readme_demos.py --check
  • .tox/py313/bin/python -m pytest tests/test_readme_demos.py -q --no-cov
  • .tox/py313/bin/python -m pytest -q --no-cov
  • .tox/py313/bin/pyright
  • .tox/ruff/bin/ruff check scripts/render_readme_demos.py tests/test_readme_demos.py
  • .tox/ruff/bin/ruff format --check scripts/render_readme_demos.py tests/test_readme_demos.py
  • git diff --check

wolph and others added 30 commits August 21, 2023 03:09
Using distutils emits a DeprecationWarning with python 3.10 at
runtime. (And the module is slated for removal in python 3.12.)

The list of accepted strings is taken from
https://docs.python.org/3/distutils/apiref.html#distutils.util.strtobool
Move the selection of whether to use N/A% to a separate method.
Include a specialization with a percentage in the center.
`GranularBar` is a widget that displays progress at a sub-character
granularity by using multiple marker characters.

Using the `GranularBar` in its default configuration will show a smooth
progress bar using unicode block characters. More examples are provided
in `examples.py`
Same idea as fbb2f4d but more generic.
Only the flushing should be wrapped, everything else should behave like
it would on the target.

The issue arises while trying to access attributes like `encoding` or
`fileno`.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request modernizes the progressbar2 library by introducing tqdm-style ergonomic options (such as desc, total, unit, unit_scale, and postfix), adding new Postfix and UnitProgress widgets, and improving print/log coexistence with a reversible logging stream wrapper. It also updates the CLI to support rate limiting and custom display flags, rewrites the README to be demo-led, and adds a script to generate SVG terminal demos. The review feedback identifies three key improvement opportunities: ensuring valid falsy values (like 0 or False) are not omitted in the Postfix widget, wrapping ProgressBarBase.finish in contextlib.suppress during error handling to prevent masking exceptions, and copying logger.handlers to a tuple during iteration to avoid concurrent modification errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread progressbar/widgets.py
Comment on lines +1268 to +1270
value = data['variables'].get(self.name)
if not value:
return ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

If value is 0, 0.0, or False, not value evaluates to True, which causes the widget to return an empty string and omit these valid postfix values. Checking for None or empty collections/strings explicitly prevents this issue.

Suggested change
value = data['variables'].get(self.name)
if not value:
return ''
value = data['variables'].get(self.name)
if value is None or (isinstance(value, (str, dict, list, set)) and not value):
return ''

Comment thread progressbar/bar.py
Comment on lines +1164 to +1170
except Exception:
with contextlib.suppress(Exception):
StdRedirectMixin.finish(self, end='')
with contextlib.suppress(Exception):
ResizableMixin.finish(self)
ProgressBarBase.finish(self)
raise

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If ProgressBarBase.finish(self) raises an exception during error handling, it will mask the original exception being raised. For robust error handling and consistency with the other cleanup calls, it should also be wrapped in contextlib.suppress(Exception).

Suggested change
except Exception:
with contextlib.suppress(Exception):
StdRedirectMixin.finish(self, end='')
with contextlib.suppress(Exception):
ResizableMixin.finish(self)
ProgressBarBase.finish(self)
raise
except Exception:
with contextlib.suppress(Exception):
StdRedirectMixin.finish(self, end='')
with contextlib.suppress(Exception):
ResizableMixin.finish(self)
with contextlib.suppress(Exception):
ProgressBarBase.finish(self)
raise

Comment thread progressbar/utils.py
Comment on lines +344 to +345
for logger_ in self._iter_loggers():
for handler in logger_.handlers:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Iterating over logger_.handlers directly can raise a RuntimeError: list changed size during iteration if another thread adds or removes a handler concurrently. Iterating over a snapshot tuple(logger_.handlers) avoids this race condition.

Suggested change
for logger_ in self._iter_loggers():
for handler in logger_.handlers:
for logger_ in self._iter_loggers():
for handler in tuple(logger_.handlers):

@wolph wolph force-pushed the harden-issue-tests branch from 5fa00aa to bd91a11 Compare June 23, 2026 01:41
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.