Skip to content
Myr

Merge stable into main (#3479)

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

authored by Rowlando13 · committed by GitHub · parents 4e869f3, 9b327da · Browse files · 7 files+32 added−6 removed
This commit

State

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

Diff stats

7 files+32 added−6 removed

  • tests:+23 added−1 removed
  • other:+9 added−5 removed

7 files+32 added−6 removed

modified:src/click/_compat.py+1 added
10 unmodified lines
11from weakref import WeakKeyDictionary1213CYGWIN = sys.platform.startswith("cygwin")14WIN = sys.platform.startswith("win")15MAC = sys.platform == "darwin"16auto_wrap_for_ansi: t.Callable[[t.TextIO], t.TextIO] | None = None17_ansi_re = re.compile(r"\033\[[;?0-9]*[a-zA-Z]")1819
608 unmodified lines
modified:src/click/_termui_impl.py+1 added-1 removed
757 unmodified lines
758 null.close()759 elif WIN:760 if locate:761 url = _unquote_file(url)762 args = ["explorer", f"/select,{url}"]762 args = ["explorer", "/select,", url]763 try:764 return subprocess.call(args)765 except OSError:766 return 127
143 unmodified lines
modified:src/click/shell_completion.py+3 added-2 removed
41 unmodified lines
42 return 14344 comp = comp_cls(cli, ctx_args, prog_name, complete_var)4546 # Write bytes, otherwise Windows text stdout translates LF to CRLF and breaks.47 if instruction == "source":47 echo(comp.source())48 echo(comp.source().encode(), nl=False)49 return 05051 if instruction == "complete":51 echo(comp.complete())52 echo(comp.complete().encode())53 return 05455 return 156
624 unmodified lines
modified:src/click/types.py+1 added-2 removed
406 unmodified lines
407 .. versionadded:: 8.0408 """409 from click.shell_completion import CompletionItem410411 str_choices = map(str, self.choices)412411 str_choices = [self.normalize_choice(choice, ctx) for choice in self.choices]412 if self.case_sensitive:413 matched = (c for c in str_choices if c.startswith(incomplete))414 else:415 incomplete = incomplete.lower()
883 unmodified lines
modified:tests/test_shell_completion.py+18 added-1 removed
1import io2import textwrap3import warnings4from collections.abc import Mapping5
5 unmodified lines
11from click.core import Group12from click.core import Option13from click.shell_completion import add_completion_class14from click.shell_completion import CompletionItem15from click.shell_completion import shell_complete16from click.shell_completion import ShellComplete17from click.types import Choice18from click.types import File19from click.types import Path
351 unmodified lines
371 result = runner.invoke(cli, env=env)372 assert result.output == expect373374375def test_source_uses_lf_line_endings(monkeypatch):376 stdout = io.BytesIO()377 stream = io.TextIOWrapper(stdout, encoding="utf-8", newline="\r\n")378 monkeypatch.setattr("click.utils._default_text_stdout", lambda: stream)379380 cli = Group("cli", commands=[Command("a"), Command("b")])381 assert shell_complete(cli, {}, "cli", "_CLI_COMPLETE", "zsh_source") == 0382383 stream.flush()384 output = stdout.getvalue()385 assert b"\r\n" not in output386 assert b"\n" in output387388389@pytest.mark.parametrize(390 ("env", "expect"),391 [392 (
79 unmodified lines
472 )473 assert result.output == "plain,a\nplain,b\n"474475476# case_sensitive=False normalizes values to lowercase, matching remains case insensitive460@pytest.mark.parametrize(("value", "expect"), [(False, ["Au", "al"]), (True, ["al"])])477@pytest.mark.parametrize(("value", "expect"), [(False, ["au", "al"]), (True, ["al"])])478def test_choice_case_sensitive(value, expect):479 cli = Command(480 "cli",481 params=[Option(["-a"], type=Choice(["Au", "al", "Bc"], case_sensitive=value))],
144 unmodified lines
modified:tests/test_utils.py+5 added
13 unmodified lines
14import pytest1516import click._termui_impl17import click.utils18from click._compat import MAC19from click._compat import WIN20from click._utils import UNSET2122
286 unmodified lines
309)310311312@pytest.mark.skipif(WIN, reason="Different behavior on windows.")313@pytest.mark.skipif(314 MAC and sys.version_info >= (3, 13) and sys._is_gil_enabled(),315 reason="Generator exception tests are flaky in Python 3.14t on macOS.",316)317@pytest.mark.parametrize(318 "pager_cmd", ["cat", "cat ", " cat ", "less", " less", " less "]319)320@pytest.mark.parametrize(
467 unmodified lines
modified:CHANGES.rst+3 added
9 unmodified lines
10-------------1112Unreleased1314- Zsh completion scripts parse correctly on Windows. :issue:`3277`15- Shell completion of `Choice` `Enum` values produces a valid completion16 result. :issue:`3015`1718Version 8.4.019-------------20
1462 unmodified lines