Skip to content

shtab: exclude 1.8.2 and 1.9.0 releases - #9983

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:shtab-exclude-broken
Jul 31, 2026
Merged

shtab: exclude 1.8.2 and 1.9.0 releases#9983
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:shtab-exclude-broken

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Fixes #9982.

shtab 1.8.2 and 1.9.0 generate broken zsh completions, so exclude just those two releases (same shape as the existing blake3>=1.0.0,!=1.0.9 exclusion right below).

Cause

shtab replaced escape_zsh() with shlex.quote() for the zsh help text (tqdm/shtab@1590207) but still interpolates the result inside a double-quoted _arguments spec. shlex.quote returns a self-contained shell word — single-quoted, with ' written as '"'"' — which is only valid at the top level. Inside "…" those quotes are literal, the parity flips, and the rest of the spec goes unquoted.

Every description with a space gained stray literal quotes, and an apostrophe anywhere left an unterminated quote that cascaded down to shtab's own default='*::: :->{name}', whose -> then parsed as a redirection:

$ borg completion zsh | zsh -n
(stdin):715: parse error near `>'

Line 715 is our borg diff --sort-by help, which contains '>size_added,path' — that's what tripped test_zsh_completion_syntax.

Why it looked macOS-only

Nothing platform-specific — zsh -n is pure parsing, and our Linux CI does install zsh. shtab was unpinned above 1.8.0 and is absent from development.lock.txt, while .tox is cached on hashFiles('…lock.txt', 'pyproject.toml'). Jobs hitting a warm cache kept the working 1.8.1; macOS 15 missed and resolved 1.8.2 fresh. The rest would have followed as caches expired.

Touching pyproject.toml changes that cache key, so this also busts the stale envs.

Upstream

Reported as tqdm/shtab#224, fix proposed in tqdm/shtab#225 (green, unmerged at time of writing). Drop the exclusions once a release carries it.

Note the exclusion style is deliberate per TW: !=1.8.2,!=1.9.0 rather than <1.8.2, so a fixed 1.9.1+ is picked up automatically. The flip side is that a future release without the fix would be allowed again.

Verification

$ pip install "shtab>=1.8.0,!=1.8.2,!=1.9.0"   # resolves to 1.8.1
$ borg completion zsh | zsh -n                  # exit 0
$ pytest src/borg/testsuite/archiver/completion_cmd_test.py

test_zsh_completion_syntax passes again. (Locally two test_bash_*_completion tests fail on this machine's bash 3.2 regardless of shtab version — unrelated, and they pass in CI.)

Both generate broken zsh completions: shtab replaced escape_zsh() with
shlex.quote() for the zsh help text, but still interpolates the result inside
a double-quoted _arguments spec. shlex.quote returns a self-contained shell
word (single-quoted, with ' written as '"'"'), which is only valid at top
level, so the quote parity flips and the rest of the spec goes unquoted.

Every description with a space gained stray literal quotes, and an apostrophe
anywhere left an unterminated quote that cascaded to shtab's own
default='*::: :->{name}', whose -> then parsed as a redirection:

    $ borg completion zsh | zsh -n
    (stdin):715: parse error near `>'

Our --sort-by help for `borg diff` contains '>size_added,path', which is what
tripped test_zsh_completion_syntax. Reported as tqdm/shtab#224, fix proposed
in tqdm/shtab#225; drop the exclusions once a release carries it.

Only CI jobs with a cold .tox cache saw this (macOS 15 first), since shtab was
unpinned above 1.8.0 -- cached envs kept the working 1.8.1.

Fixes borgbackup#9982
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.86%. Comparing base (3a864cd) to head (fb7c717).
⚠️ Report is 9 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9983      +/-   ##
==========================================
+ Coverage   85.84%   85.86%   +0.01%     
==========================================
  Files          95       95              
  Lines       17056    17064       +8     
  Branches     2614     2614              
==========================================
+ Hits        14642    14652      +10     
+ Misses       1674     1673       -1     
+ Partials      740      739       -1     

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

@ThomasWaldmann
ThomasWaldmann merged commit a05a763 into borgbackup:master Jul 31, 2026
15 of 16 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the shtab-exclude-broken branch July 31, 2026 15:37
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.

zsh completions broken?

1 participant