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
Provenance
- Commit
51736b9- Tree
3b94a33- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
f00d15e
3 files changed+2 added−49 removed
modified:src/click/core.py-35 removed
2007 unmodified lines2008 [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 lines2031 self.default = default2032 self.is_eager = is_eager2033 self.metavar = metavar2034 self.envvar = envvar2040-2041- if autocompletion is not None:2042- import warnings2043-2044- 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- )2051-2052- def shell_complete(2053- ctx: Context, param: "Parameter", incomplete: str2054- ) -> t.List["CompletionItem"]:2055- from click.shell_completion import CompletionItem2056-2057- out = []2058-2059- 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)2064-2065- if c.value.startswith(incomplete):2066- out.append(c)2067-2068- return out2069-2035 self._custom_shell_complete = shell_complete2036 2037 if __debug__:2038 if self.type.is_composite and nargs != self.type.arity:876 unmodified linesmodified:tests/test_shell_completion.py-14 removed
159 unmodified lines160 assert _get_words(cli, ["a", "b"], "") == [""]161 assert _get_words(cli, ["a", "b"], "c") == ["C"]162 163 164-def 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"]170-171- with pytest.deprecated_call():172- cli = Command("cli", params=[Argument(["x"], autocompletion=custom)])173-174- assert _get_words(cli, [], "") == ["art", "bat", "cat"]175- assert _get_words(cli, [], "c") == ["cat"]176-177-164 def test_option_multiple():165 cli = Command(166 "type",167 params=[Option(["-m"], type=Choice(["a", "b"]), multiple=True), Option(["-f"])],138 unmodified linesmodified:CHANGES.rst+2 added
7 unmodified lines8 - Drop support for Python 3.6. :pr:`2129`9 - Remove previously deprecated code. :pr:`2130`10 11 - ``Group.resultcallback`` is renamed to ``result_callback``.12+ - ``autocompletion`` parameter to ``Command`` is renamed to13+ ``shell_complete``.14 15 - Single options boolean flags with ``show_default=True`` only show16 the default if it is ``True``. :issue:`1971`17 942 unmodified lines