Skip to content

Commit b745b17

Browse files
committed
πŸ› fix(coverage): remove dead _strip_ansi_colors path
After consolidating the ANSI stripping into _mk_sub_command's version guard, the stripped parameter in _build_sub_cmd_title became dead code β€” its only caller always passed stripped=True. This left _strip_ansi_colors unreachable on Python <3.14, failing coverage on those versions.
1 parent 97486c0 commit b745b17

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

β€Žsrc/sphinx_argparse_cli/_logic.pyβ€Ž

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _mk_sub_command(self, aliases: list[str], help_msg: str, parser: ArgumentPar
335335
# https://github.com/python/cpython/issues/139809
336336
parser.prog = _strip_ansi_colors(parser.prog)
337337

338-
title_text = self._build_sub_cmd_title(parser, sub_title_prefix, title_prefix, stripped=True)
338+
title_text = self._build_sub_cmd_title(parser, sub_title_prefix, title_prefix)
339339
title_ref: str = parser.prog
340340
if aliases:
341341
aliases_text: str = f" ({', '.join(aliases)})"
@@ -366,12 +366,9 @@ def _mk_sub_command(self, aliases: list[str], help_msg: str, parser: ArgumentPar
366366
group_section += self._mk_option_group(group, prefix=parser.prog)
367367
return group_section
368368

369-
def _build_sub_cmd_title(
370-
self, parser: ArgumentParser, sub_title_prefix: str, title_prefix: str, *, stripped: bool = False
371-
) -> str:
372-
prog = parser.prog if stripped else _strip_ansi_colors(parser.prog)
373-
elements = prog.split(" ")
374-
return self._resolve_prefix(elements[0], elements[1], prog, title_prefix, sub_title_prefix).rstrip()
369+
def _build_sub_cmd_title(self, parser: ArgumentParser, sub_title_prefix: str, title_prefix: str) -> str:
370+
elements = parser.prog.split(" ")
371+
return self._resolve_prefix(elements[0], elements[1], parser.prog, title_prefix, sub_title_prefix).rstrip()
375372

376373
def _resolve_prefix(
377374
self,
@@ -445,8 +442,7 @@ def _parse_known_args_hook(self: ArgumentParser, *args: Any, **kwargs: Any) -> N
445442
_ANSI_COLOR_RE = re.compile(r"\x1b\[[0-9;]*m")
446443

447444

448-
def _strip_ansi_colors(text: str) -> str:
449-
"""Remove ANSI color/style escape sequences (SGR codes) from text."""
445+
def _strip_ansi_colors(text: str) -> str: # pragma: >=3.14 cover
450446
# needed due to https://github.com/python/cpython/issues/139809
451447
return _ANSI_COLOR_RE.sub("", text)
452448

0 commit comments

Comments
Β (0)