diff options
author | David Lord <davidism@gmail.com> | 2021-11-10 16:42:17 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-11-10 16:42:17 -0800 |
commit | 51736b9566637351362f1eaeb32ea42aecdec704 (patch) | |
tree | 3b94a33be85efd9a6211bbde080139f249d54328 | |
parent | f00d15eeeaf4d789ac6a7840c43fb54aabe7fe3f (diff) | |
download | click-51736b9566637351362f1eaeb32ea42aecdec704.tar.gz |
remove deprecated Command autocompletion parameter
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | src/click/core.py | 35 | ||||
-rw-r--r-- | tests/test_shell_completion.py | 14 |
3 files changed, 2 insertions, 49 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 7f288fe..cc12060 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,8 @@ Unreleased - Remove previously deprecated code. :pr:`2130` - ``Group.resultcallback`` is renamed to ``result_callback``. + - ``autocompletion`` parameter to ``Command`` is renamed to + ``shell_complete``. - Single options boolean flags with ``show_default=True`` only show the default if it is ``True``. :issue:`1971` diff --git a/src/click/core.py b/src/click/core.py index 667dcee..ba6877b 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -2009,11 +2009,6 @@ class Parameter: t.Union[t.List["CompletionItem"], t.List[str]], ] ] = None, - autocompletion: t.Optional[ - t.Callable[ - [Context, t.List[str], str], t.List[t.Union[t.Tuple[str, str], str]] - ] - ] = None, ) -> None: self.name, self.opts, self.secondary_opts = self._parse_decls( param_decls or (), expose_value @@ -2037,36 +2032,6 @@ class Parameter: self.is_eager = is_eager self.metavar = metavar self.envvar = envvar - - if autocompletion is not None: - import warnings - - warnings.warn( - "'autocompletion' is renamed to 'shell_complete'. The old name is" - " deprecated and will be removed in Click 8.1. See the docs about" - " 'Parameter' for information about new behavior.", - DeprecationWarning, - stacklevel=2, - ) - - def shell_complete( - ctx: Context, param: "Parameter", incomplete: str - ) -> t.List["CompletionItem"]: - from click.shell_completion import CompletionItem - - out = [] - - for c in autocompletion(ctx, [], incomplete): # type: ignore - if isinstance(c, tuple): - c = CompletionItem(c[0], help=c[1]) - elif isinstance(c, str): - c = CompletionItem(c) - - if c.value.startswith(incomplete): - out.append(c) - - return out - self._custom_shell_complete = shell_complete if __debug__: diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py index 8338d0e..08fa057 100644 --- a/tests/test_shell_completion.py +++ b/tests/test_shell_completion.py @@ -161,20 +161,6 @@ def test_option_custom(): assert _get_words(cli, ["a", "b"], "c") == ["C"] -def test_autocompletion_deprecated(): - # old function takes args and not param, returns all values, can mix - # strings and tuples - def custom(ctx, args, incomplete): - assert isinstance(args, list) - return [("art", "x"), "bat", "cat"] - - with pytest.deprecated_call(): - cli = Command("cli", params=[Argument(["x"], autocompletion=custom)]) - - assert _get_words(cli, [], "") == ["art", "bat", "cat"] - assert _get_words(cli, [], "c") == ["cat"] - - def test_option_multiple(): cli = Command( "type", |