Skip to content

Remove source-code indentation from multi-line terminal messages - #124

Merged
zfleeman merged 1 commit into
mainfrom
zf/message-indentation
Oct 22, 2026
Merged

zfleeman merged 1 commit into
mainfrom
zf/message-indentation

Conversation

@zfleeman

Copy link
Copy Markdown
Owner

Closes #123.

Changes

  1. No more source-code indentation. 10 multi-line terminal messages were written as dedent(f"""\033[31m .... dedent() only removes indentation that every line shares, and the first line (the color code) had none, so every line kept up to 24 spaces of indentation. Each message now dedents plain text and adds the color codes around the result:

    "\033[31m"
    + dedent(
        """
        Some message.
        """
    ).strip()
    + "\033[0m"

    The colors don't change: red for errors and warnings, yellow for the update notice. The messages are in twopass.py (FFmpeg failure, HDR, "Time Paradox?", output extension, framerate, aspect ratio), __main__.py (retry "Restarting...", update notice), arguments.py (invalid --astreams), and windows.py (not-Windows warning).

  2. FFmpeg failure hint. The hardware-encoder hint used to be a separate red block glued to the end of the message. It's now its own paragraph inside the same red text.

  3. "Time Paradox?" video length. It now shows the length as a timestamp, like the clip times on the next line: "Your video is 00:00:54.747 long" instead of "0.9124507000000001 minutes".

  4. Typo. "croped" is now "cropped" in the aspect-ratio warning.

Since .strip() removes the leading newline, each message now starts on the same line as ERROR:root: or WARNING:root: instead of on the line after it.

Testing

  • uv run pytest --cov: 286 passed, 99% coverage. ruff format and ruff check are clean.
  • New test: the "Time Paradox?" ValueError has no line starting with a space, and shows "Your video is 00:02:00 long" for the 120-second test video.
  • The hint test now checks that the hint is the last paragraph, inside the red text.
  • Real runs on example.mp4 (trimmed to 10 seconds), with the color codes shown by cat -v: "Time Paradox?", invalid --astreams, the output extension, framerate, and aspect-ratio warnings, the h264_nvenc failure with its hint, and the windows.py warning on macOS all start at the left edge and are red from start to end. The retry message and the update notice weren't triggered: they need an oversized output and a newer PyPI release.

@zfleeman
zfleeman merged commit 3a64c5c into main Oct 22, 2026
11 of 12 checks passed
@zfleeman
zfleeman deleted the zf/message-indentation branch October 22, 2026 17:28
@zfleeman zfleeman mentioned this pull request Oct 22, 2026
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.

Multi-line terminal messages keep their source-code indentation

1 participant