Skip to content

Accept the documented VtScreenView diff baseline #90

Backlog

Description

@tony

Summary

A view that serializes alone and satisfies the public diff annotation raises TypeError when passed as another view’s baseline.

Reproduction

  1. From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory.

  2. Save the following as case.py at the checkout root.

from libvt import Terminal
from libvt.testing import serialize_vt_snapshot, vt_screen

term = Terminal(rows=1, cols=10)
term.feed(b"PENDING")
before = term.committed
term.feed(b"\r\x1b[2KAPPROVED")
assert "APPROVED" in serialize_vt_snapshot(vt_screen(term, diff=before))
baseline = vt_screen(before, include_styles=False)
assert "PENDING" in serialize_vt_snapshot(baseline)
try:
    print(serialize_vt_snapshot(vt_screen(term, diff=baseline)))
except TypeError as error:
    print(type(error).__name__, str(error))
    raise SystemExit(1) from None
  1. Run the case.
$ uv run --no-sync python case.py

Expected

The typed call should produce a row diff, with a defined rule for inherited view options.

Actual

The bare snapshot succeeds and the wrapped baseline fails with its type named in the exception.

Environment

Tested versions

CPython 3.14.6 on Linux ARM64 under WSL2. The example produced the reported result against both v0.0.1a4 and the tested trunk revision.

Evidence

Observed output
TypeError Expected Terminal, Snapshot, Screen, RegionView, or VT pane wrapper for diff, got VtScreenView

Proposal

Normalize both targets through the existing view logic. Specify how conflicting regional or formatting options are applied and check accepted and rejected calls with ty.

  • Developer experience — A fixture can return a prepared baseline that works everywhere a diff is requested.
  • Immediate benefit — Capturing and comparing a reusable view stops failing at serialization time.
  • Longer-term benefit — Typed snapshot views become composable across pytest and Syrupy.
  • End-user experience — A developer sees the changed terminal row instead of a type exception.

References

Activity

  1. added
    bug
    p2
    on Nov 30, 2026
  2. tony commented on Dec 3, 2026

    @tony
    MemberAuthor

    PR #191 accepts a prepared single-frame baseline and builds on #151’s single-frame diff. In a five-column frame, changing 界X to 界Y reported row 0 cols 2..3 for both bare and prepared baselines. Bypassing the prepared-view path made the regression fail again. PR #191 · PR #151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions