Skip to content
Myr

completion arguments may start with a "/"

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sam Schott · committed by David Lord · parent 2184ab1 · Browse files · 3 files+16 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+16 added−1 removed

  • tests:+8 added−0 removed
  • other:+8 added−1 removed

3 files+16 added−1 removed

modified:src/click/shell_completion.py+6 added-1 removed
448 unmodified lines
449450451def _start_of_option(value: str) -> bool:452 """Check if the value looks like the start of an option."""453 return not value[0].isalnum() if value else False453 if not value:454 return False455456 c = value[0]457 # Allow "/" since that starts a path.458 return not c.isalnum() and c != "/"459460461def _is_incomplete_option(args: t.List[str], param: Parameter) -> bool:462 """Determine if the given parameter is an option that needs a value.463464 :param args: List of complete args before the incomplete value.
117 unmodified lines
modified:tests/test_shell_completion.py+8 added
123 unmodified lines
124 assert c.value == "ab"125 assert c.type == expect126127128def test_absolute_path():129 cli = Command("cli", params=[Option(["-f"], type=Path())])130 out = _get_completions(cli, ["-f"], "/ab")131 assert len(out) == 1132 c = out[0]133 assert c.value == "/ab"134135136def test_option_flag():137 cli = Command(138 "cli",139 add_help_option=False,
183 unmodified lines
modified:CHANGES.rst+2 added
8 unmodified lines
9 :issue:`1925`10- Bash version detection is locale independent. :issue:`1940`11- Empty ``default`` value is not shown for ``multiple=True``.12 :issue:`1969`13- Fix shell completion for arguments that start with a forward slash14 such as absolute file paths. :issue:`1929`151617Version 8.0.118-------------
889 unmodified lines