Repository navigation
Done
Labels
enhancementNew feature or request
Description
Summary
Wave 4 final pre-0.1.0 cutover slice of #34 (gated on Waves 1–3): shrink src/libvt/__init__.py to the quickstart core behind a static PEP 562 __getattr__ and __dir__ map, gate pytest11 startup imports in tests/test_libvt.py, and run a single mechanical cross-reference sweep across conftest.py, tests/, docs/, docs/project/public-api.md, and MIGRATION.
Motivation
.github/CONTRIBUTING.mdrequiressrc/libvt/pytest_plugin.pyto keep top-level imports light duringpytestcollection, yet Python executessrc/libvt/__init__.pyfirst wheneverlibvt.pytest_pluginloads, eagerly importinglibvt._ucd,libvt.terminal,libvt.graphics, andlibvt.statusintosys.modules.- Sequencing this slice in Wave 4—after
Appearance,KnownEvent,libvt.profiles, andlibvt.contrib.tmuxsit in their final modules—lets__all__, Sphinx{class}targets, andMIGRATIONupdate once instead of churning on every earlier wave.
Proposal
- Replace eager submodule imports in
src/libvt/__init__.pywithfrom .__about__ import __version__, anif t.TYPE_CHECKING:static re-export block forty/pyright/mypy, and a table-driven PEP 562__getattr__+__dir__map serving onlyTerminal,Snapshot,Screen,Cell,Style,Appearance,Profile,Policy,Limits,Event,render,strip,LibVtError,ProtocolError, and__version__. - Preserve each class and function's defining submodule in
__module__(never rewriting__module__ = "libvt") so Sphinx autodoc,pickle, and tracebacks point to one canonical path (libvt.modes.Mode,libvt.input.KeyEvent,libvt.profiles.XTERM_PROFILE,libvt.contrib.tmux.decode_tmux_capture). - Add subprocess
sys.modulesassertions intests/test_libvt.pyverifying thatimport libvtandimport libvt.pytest_pluginload neitherlibvt.terminalnorlibvt._ucd, and that every name inlibvt.__all__resolves identically under runtimegetattr(libvt, name)and static type checking. - Sweep remaining
libvt.<attr>accesses intests/, update_seed_doctest_namespaceinconftest.pyif needed, update MyST{class}/{func}targets acrossdocs/(just build-docsclean), and document relocated import paths indocs/project/public-api.mdandMIGRATION.
Alternatives
- Keeping all submodule symbols in
libvt.__all__behind lazy PEP 562 lookups: rejected because a flat package root freezes submodule symbol names across unrelated layers (codec,graphics,status,input,contrib) into permanent root API surface at0.1.0.
References
- Design specification and roadmap: Move
tmuxtolibvt.contrib.tmuxand harden pre-0.1core APIs #34,0.0.xto0.1.0and beyond Roadmap #35 - Files touched at 6c33073:
src/libvt/__init__.py,src/libvt/pytest_plugin.py,conftest.py,tests/test_libvt.py,docs/project/public-api.md,MIGRATION - Specification: PEP 562 — Module
__getattr__and__dir__
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsDone
Activity
0.1.0API waves aroundterminal.pyserialization #36Profileinto capability groups and addlibvt.profiles#37Eventan open base class and normalizeOSC 133/OSC 633#38tmuxinto decoupledlibvt.contrib.tmuxsubmodules #39OSC 52Policycontrols inlibvt#40Appearanceacross?2026holds andset_theme()#41?8/?66/?67input modes,MouseTracker, andAsyncSession#42XTSAVE(CSI ? Pm s) andXTRESTORE(CSI ? Pm r) private mode save/restore #29