Skip to content

Make safe_invalidate_display() safer with a try block#1685

Open
rolandwalker wants to merge 1 commit intomainfrom
RW/safer-invalidate-display
Open

Make safe_invalidate_display() safer with a try block#1685
rolandwalker wants to merge 1 commit intomainfrom
RW/safer-invalidate-display

Conversation

@rolandwalker
Copy link
Contributor

Description

It would be possible to place a call to this function before it could work. The "try" makes it safe against throwing in every runtime case.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

It would be possible to place a call to this function before it could
work.  The "try" makes it safe against throwing in every runtime case.
@rolandwalker rolandwalker self-assigned this Mar 7, 2026
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

  1. Potential bug masking due to broad RuntimeError catch
    In utils.py:20, except RuntimeError: pass will suppress all RuntimeErrors from run_in_terminal(...), not just the “called too early / app not running” case described in the PR.
    Action: narrow handling to the specific expected condition (or guard preconditions before calling), and log unexpected runtime failures at debug level so real regressions aren’t silently hidden.

  2. Missing test coverage for new exception behavior
    The PR changes control flow in utils.py:20 but adds no tests.
    Action: add unit tests that verify:

    • safe_invalidate_display does not raise when run_in_terminal raises the expected runtime condition.
    • unexpected exceptions are still surfaced (or explicitly documented if intentionally swallowed).

No security issues were evident in this diff.

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.

1 participant