Skip to content

neo(fix[parse_output]): Keep empty tmux fields as empty strings - #900

Merged
tony merged 4 commits into
masterfrom
fix/445-empty-string-fields
Nov 27, 2026
Merged

tony merged 4 commits into
masterfrom
fix/445-empty-string-fields

Conversation

@tony

@tony tony commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Breaking change. Read Before / After below before merging.

Summary

  • Preserve empty format values as "" in parse_output() instead of dropping them to None.
  • Reserve None on Obj fields for format tokens not requested by the listing command or running tmux version.
  • Update Session, Window, and Pane field docstrings and document the migration in CHANGES and MIGRATION.

Fixes #445

Before / After

Before, a cleared or empty format token such as pane_title or session_group read back as None:

pane.set_title("")
pane.refresh()
pane.pane_title is None

After, requested tokens that tmux reports as empty read back as "", so emptiness checks use truthiness (not pane.pane_title):

pane.set_title("")
pane.refresh()
pane.pane_title == ""

Design decisions

  • None now has one meaning on Obj instances: the token was not requested (for example a client-only token on list-sessions, or a token gated on a newer tmux release than the connected server). An empty answer from tmux is "", matching tmux's own format expansion in format.c.
  • Callers testing value is None for empty string tokens (pane_title, session_group, pane_dead_status, window_name) switch to not value.

Test plan

  • test_empty_field_is_an_empty_string and test_refresh_clears_a_field_tmux_emptied verify "" on fresh Pane.from_pane_id() reads and after refresh()
  • parse_output and MIGRATION doctests verify requested empty fields ("") vs unrequested fields (None)
  • ruff check, ruff format --check, mypy, and sphinx-build -W
  • Full tmux version matrix in CI

@tony tony added the behavior-change Fixes a bug by changing observable or documented behaviour; needs a minor release label Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.58%. Comparing base (4797b58) to head (30a010f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
- Coverage   57.71%   57.58%   -0.13%     
==========================================
  Files          29       29              
  Lines        4363     4362       -1     
  Branches      882      882              
==========================================
- Hits         2518     2512       -6     
- Misses       1535     1539       +4     
- Partials      310      311       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony force-pushed the fix/445-empty-string-fields branch 2 times, most recently from 51e68f3 to d63e4d9 Compare November 21, 2026 22:09
@tony tony mentioned this pull request Nov 21, 2026
33 of 58 tasks
@tony
tony force-pushed the fix/445-empty-string-fields branch 4 times, most recently from cc91ec9 to 6cae484 Compare November 22, 2026 19:27
@tony tony added the area: options-formats Options, formats, names, targets label Nov 24, 2026
@tony tony added this to the 0.69.0 milestone Nov 24, 2026
@tony
tony force-pushed the fix/445-empty-string-fields branch from 6cae484 to 37c1c6c Compare November 25, 2026 08:13
@tony tony added this to libtmux Nov 25, 2026
@tony tony moved this to In Progress in libtmux Nov 25, 2026
tony added a commit that referenced this pull request Nov 26, 2026
…note

Update Session, Window, and Pane class docstrings so '' vs None matches
parse_output(), add a tested MIGRATION entry for #900, and drop the
duplicate TYPE_CHECKING guard in tests/test_neo.py.
tony added 4 commits November 26, 2026 19:18
why: parse_output dropped every empty value, so a field tmux reports
as empty read as None, the same as a field tmux was never asked for,
and refresh() kept the old value of a field tmux had emptied.

what:
- Return every requested field from parse_output, "" when empty
- Test a cleared pane title after refresh() and on a new object
- Update the parse_output doctest
why: An empty field and a field tmux was never asked for both read as
None, and callers need to know the first now reads as "".

what:
- Add a Breaking changes entry for empty fields, with the migration
…note

Update Session, Window, and Pane class docstrings so '' vs None matches
parse_output(), add a tested MIGRATION entry for #900, and drop the
duplicate TYPE_CHECKING guard in tests/test_neo.py.
@tony
tony force-pushed the fix/445-empty-string-fields branch from 3114b9d to 30a010f Compare November 27, 2026 01:20
@tony
tony merged commit 8d9d823 into master Nov 27, 2026
15 checks passed
@tony
tony deleted the fix/445-empty-string-fields branch November 27, 2026 01:23
@github-project-automation github-project-automation Bot moved this from In Progress to Done in libtmux Nov 27, 2026
@tony tony mentioned this pull request Nov 28, 2026
7 tasks done
tony added a commit to tmux-python/tmuxp that referenced this pull request Nov 28, 2026
why: Pick up libtmux 0.69.0. Server context managers leave a running
tmux server alive on exit unless kill_on_exit=True is set, @ user
options stay strings in show_option() and show_options(), and empty tmux
format fields hydrate as "" instead of None while unset fields stay
None. tmuxp requires no source changes for the upgrade.

what:
- Bump libtmux ~=0.68.0 -> ~=0.69.0 in pyproject.toml
- Update uv.lock to libtmux 0.69.0 from PyPI (only libtmux moves)

libtmux 0.69.0 (2026-11-27):
- Server.__exit__() preserves running servers unless kill_on_exit=True
  is set (tmux-python/libtmux#728)
- @ user options stay strings in show_option() and show_options()
  (tmux-python/libtmux#826)
- Empty tmux format fields hydrate as "" while unset fields stay None
  (tmux-python/libtmux#900)

See also:
- https://github.com/tmux-python/libtmux/releases/tag/v0.69.0
- https://libtmux.git-pull.com/history/#libtmux-0-69-0-2026-11-27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: options-formats Options, formats, names, targets behavior-change Fixes a bug by changing observable or documented behaviour; needs a minor release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

parse_output drops "" values and Obj._refresh leaves stale fields

1 participant