Skip to content

Disable animation for NO_COLOR + TERM=dumb - #584

Open
hagenw wants to merge 2 commits into
mainfrom
disable-shimmer-via-env
Open

Disable animation for NO_COLOR + TERM=dumb#584
hagenw wants to merge 2 commits into
mainfrom
disable-shimmer-via-env

Conversation

@hagenw

@hagenw hagenw commented Jul 20, 2026

Copy link
Copy Markdown
Member

Closes #582

Skips the shimmer animation if the environment variable NO_COLOR is set or the environment variable TERM is set to dumb.

@hagenw hagenw self-assigned this Jul 20, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Implements environment-controlled disabling of shimmer animations via NO_COLOR and TERM=dumb, centralizes the logic in a new helper, and adds tests/fixtures to ensure shimmer becomes a no-op while still printing static text once when animations are disabled.

Sequence diagram for shimmer.start behavior with NO_COLOR and TERM=dumb

sequenceDiagram
    actor User
    participant Shimmer
    participant sys_stdout
    participant animations_enabled

    User->>Shimmer: start()
    Shimmer->>sys_stdout: hasattr(sys_stdout, isatty)
    Shimmer->>sys_stdout: isatty()
    Shimmer->>animations_enabled: animations_enabled()

    alt interactive_tty and animations_enabled
        Shimmer->>Shimmer: _start_animation_thread()
    else non_interactive or animations_disabled
        Shimmer->>sys_stdout: write(prefix + text + suffix + "\n")
        Shimmer->>sys_stdout: flush()
        Shimmer->>Shimmer: _noop = True
    end
Loading

File-Level Changes

Change Details Files
Add centralized environment check to determine whether terminal animations are allowed and use it in Shimmer.start.
  • Introduce animations_enabled() helper that disables animations when NO_COLOR is set to a non-empty value or TERM is 'dumb', otherwise returns True
  • Update Shimmer.start() to also skip animations when animations_enabled() is False, while still printing the static text once and marking the instance as a no-op
  • Extend shimmer() context manager docstring to document that animations are skipped in non-interactive environments and when NO_COLOR or TERM=dumb disables them
audb/core/shimmer.py
Add tests ensuring shimmer behavior respects NO_COLOR/TERM=dumb and isolate tests from ambient environment.
  • Import pytest and the new animations_enabled() helper into the shimmer tests
  • Add an autouse fixture that clears NO_COLOR and sets TERM to a sane default so external environment does not influence tests
  • Add tests for animations_enabled() behavior across different NO_COLOR and TERM combinations
  • Add parametrized test verifying that shimmer becomes a no-op (no stdout.write patching) but still prints the static line exactly once when NO_COLOR or TERM=dumb are set, even when stdout is a TTY
tests/test_shimmer.py

Assessment against linked issues

Issue Objective Addressed Explanation
#582 Disable the shimmer animation when the environment indicates that animations/colors should not be used (e.g., NO_COLOR set, TERM=dumb), while still printing the static text once.
#582 Add or update tests to cover the new environment-based shimmer disabling behavior to prevent shimmer output from appearing in logs.
#582 Document the new behavior of shimmer being skipped in environments disabling animations (NO_COLOR, TERM=dumb) in the shimmer implementation docstrings.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hagenw hagenw changed the title Disable shimmer animation for NO_COLOR + TERM=dumb Disable animation for NO_COLOR + TERM=dumb Jul 20, 2026
sourcery-ai[bot]

This comment was marked as resolved.

@hagenw

hagenw commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

@frankenjoe this branch should disable the animation if you run NO_COLOR=1 screen -L .... Maybe you can check if the progress bar is still appearing in the logs and we also need to disable it.

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.

Shimmer animation can appear in logs

1 participant