Skip to content
Myr

remove deprecated Command autocompletion parameter

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

authored by David Lord · committed by David Lord · parent f00d15e · Browse files · 3 files+2 added−49 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+2 added−49 removed

  • tests:+0 added−14 removed
  • other:+2 added−35 removed

3 files+2 added−49 removed

modified:src/click/core.py-35 removed
2007 unmodified lines
2008 [Context, "Parameter", str],2009 t.Union[t.List["CompletionItem"], t.List[str]],2010 ]2011 ] = None,2012 autocompletion: t.Optional[2013 t.Callable[2014 [Context, t.List[str], str], t.List[t.Union[t.Tuple[str, str], str]]2015 ]2016 ] = None,2012 ) -> None:2013 self.name, self.opts, self.secondary_opts = self._parse_decls(2014 param_decls or (), expose_value2015 )
15 unmodified lines
2031 self.default = default2032 self.is_eager = is_eager2033 self.metavar = metavar2034 self.envvar = envvar20402041 if autocompletion is not None:2042 import warnings20432044 warnings.warn(2045 "'autocompletion' is renamed to 'shell_complete'. The old name is"2046 " deprecated and will be removed in Click 8.1. See the docs about"2047 " 'Parameter' for information about new behavior.",2048 DeprecationWarning,2049 stacklevel=2,2050 )20512052 def shell_complete(2053 ctx: Context, param: "Parameter", incomplete: str2054 ) -> t.List["CompletionItem"]:2055 from click.shell_completion import CompletionItem20562057 out = []20582059 for c in autocompletion(ctx, [], incomplete): # type: ignore2060 if isinstance(c, tuple):2061 c = CompletionItem(c[0], help=c[1])2062 elif isinstance(c, str):2063 c = CompletionItem(c)20642065 if c.value.startswith(incomplete):2066 out.append(c)20672068 return out20692035 self._custom_shell_complete = shell_complete20362037 if __debug__:2038 if self.type.is_composite and nargs != self.type.arity:
876 unmodified lines
modified:tests/test_shell_completion.py-14 removed
159 unmodified lines
160 assert _get_words(cli, ["a", "b"], "") == [""]161 assert _get_words(cli, ["a", "b"], "c") == ["C"]162163164def test_autocompletion_deprecated():165 # old function takes args and not param, returns all values, can mix166 # strings and tuples167 def custom(ctx, args, incomplete):168 assert isinstance(args, list)169 return [("art", "x"), "bat", "cat"]170171 with pytest.deprecated_call():172 cli = Command("cli", params=[Argument(["x"], autocompletion=custom)])173174 assert _get_words(cli, [], "") == ["art", "bat", "cat"]175 assert _get_words(cli, [], "c") == ["cat"]176177164def test_option_multiple():165 cli = Command(166 "type",167 params=[Option(["-m"], type=Choice(["a", "b"]), multiple=True), Option(["-f"])],
138 unmodified lines
modified:CHANGES.rst+2 added
7 unmodified lines
8- Drop support for Python 3.6. :pr:`2129`9- Remove previously deprecated code. :pr:`2130`1011 - ``Group.resultcallback`` is renamed to ``result_callback``.12 - ``autocompletion`` parameter to ``Command`` is renamed to13 ``shell_complete``.1415- Single options boolean flags with ``show_default=True`` only show16 the default if it is ``True``. :issue:`1971`17
942 unmodified lines