Skip to content
Myr

Merge pull request #2130 from pallets/remove-deprecated-code

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

remove deprecated code

authored by David Lord · committed by GitHub · parents 4b4e2bd, 60a5eaf · Browse files · 7 files+9 added−103 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+9 added−103 removed

  • tests:+0 added−14 removed
  • other:+9 added−89 removed

7 files+9 added−103 removed

modified:docs/api.rst-2 removed
61 unmodified lines
62.. autofunction:: getchar6364.. autofunction:: pause6566.. autofunction:: get_terminal_size6766.. autofunction:: get_binary_stream6768.. autofunction:: get_text_stream69
140 unmodified lines
modified:src/click/__init__.py-2 removed
39 unmodified lines
40from .termui import clear as clear41from .termui import confirm as confirm42from .termui import echo_via_pager as echo_via_pager43from .termui import edit as edit44from .termui import get_terminal_size as get_terminal_size44from .termui import getchar as getchar45from .termui import launch as launch46from .termui import pause as pause47from .termui import progressbar as progressbar
18 unmodified lines
66from .utils import echo as echo67from .utils import format_filename as format_filename68from .utils import get_app_dir as get_app_dir69from .utils import get_binary_stream as get_binary_stream71from .utils import get_os_args as get_os_args70from .utils import get_text_stream as get_text_stream71from .utils import open_file as open_file7273__version__ = "8.1.0.dev0"
modified:src/click/core.py-46 removed
1566 unmodified lines
1567 return rv15681569 return decorator15701571 def resultcallback(self, replace: bool = False) -> t.Callable[[F], F]:1572 import warnings15731574 warnings.warn(1575 "'resultcallback' has been renamed to 'result_callback'."1576 " The old name will be removed in Click 8.1.",1577 DeprecationWarning,1578 stacklevel=2,1579 )1580 return self.result_callback(replace=replace)15811571 def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None:1572 """Extra format methods for multi methods that adds all the commands1573 after the options.1574 """
433 unmodified lines
2008 [Context, "Parameter", str],2009 t.Union[t.List["CompletionItem"], t.List[str]],2010 ]2011 ] = None,2023 autocompletion: t.Optional[2024 t.Callable[2025 [Context, t.List[str], str], t.List[t.Union[t.Tuple[str, str], str]]2026 ]2027 ] = 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 = envvar20512052 if autocompletion is not None:2053 import warnings20542055 warnings.warn(2056 "'autocompletion' is renamed to 'shell_complete'. The old name is"2057 " deprecated and will be removed in Click 8.1. See the docs about"2058 " 'Parameter' for information about new behavior.",2059 DeprecationWarning,2060 stacklevel=2,2061 )20622063 def shell_complete(2064 ctx: Context, param: "Parameter", incomplete: str2065 ) -> t.List["CompletionItem"]:2066 from click.shell_completion import CompletionItem20672068 out = []20692070 for c in autocompletion(ctx, [], incomplete): # type: ignore2071 if isinstance(c, tuple):2072 c = CompletionItem(c[0], help=c[1])2073 elif isinstance(c, str):2074 c = CompletionItem(c)20752076 if c.value.startswith(incomplete):2077 out.append(c)20782079 return out20802035 self._custom_shell_complete = shell_complete20362037 if __debug__:2038 if self.type.is_composite and nargs != self.type.arity:
876 unmodified lines
modified:src/click/termui.py-20 removed
250 unmodified lines
251 raise Abort()252 return rv253254255def get_terminal_size() -> os.terminal_size:256 """Returns the current size of the terminal as tuple in the form257 ``(width, height)`` in columns and rows.258259 .. deprecated:: 8.0260 Will be removed in Click 8.1. Use261 :func:`shutil.get_terminal_size` instead.262 """263 import shutil264 import warnings265266 warnings.warn(267 "'click.get_terminal_size()' is deprecated and will be removed"268 " in Click 8.1. Use 'shutil.get_terminal_size()' instead.",269 DeprecationWarning,270 stacklevel=2,271 )272 return shutil.get_terminal_size()273274255def echo_via_pager(256 text_or_generator: t.Union[t.Iterable[str], t.Callable[[], t.Iterable[str]], str],257 color: t.Optional[bool] = None,258) -> None:
531 unmodified lines
modified:src/click/utils.py-19 removed
377 unmodified lines
378379 return f380381382def get_os_args() -> t.Sequence[str]:383 """Returns the argument part of ``sys.argv``, removing the first384 value which is the name of the script.385386 .. deprecated:: 8.0387 Will be removed in Click 8.1. Access ``sys.argv[1:]`` directly388 instead.389 """390 import warnings391392 warnings.warn(393 "'get_os_args' is deprecated and will be removed in Click 8.1."394 " Access 'sys.argv[1:]' directly instead.",395 DeprecationWarning,396 stacklevel=2,397 )398 return sys.argv[1:]399400382def format_filename(383 filename: t.Union[str, bytes, os.PathLike], shorten: bool = False384) -> str:385 """Formats a filename for user display. The main purpose of this
184 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+9 added
4 unmodified lines
56Unreleased78- 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``.14 - ``get_terminal_size`` is removed, use15 ``shutil.get_terminal_size`` instead.16 - ``get_os_args`` is removed, use ``sys.argv[1:]`` instead.1718- Single options boolean flags with ``show_default=True`` only show19 the default if it is ``True``. :issue:`1971`2021
941 unmodified lines