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
Provenance
- Commit
6411f42- Tree
af6a529- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
4b4e2bd- Parent 2
60a5eaf
7 files changed+9 added−103 removed
modified:docs/api.rst-2 removed
61 unmodified lines62 .. autofunction:: getchar63 64 .. autofunction:: pause65 66-.. autofunction:: get_terminal_size67-66 .. autofunction:: get_binary_stream67 68 .. autofunction:: get_text_stream69 140 unmodified linesmodified:src/click/__init__.py-2 removed
39 unmodified lines40 from .termui import clear as clear41 from .termui import confirm as confirm42 from .termui import echo_via_pager as echo_via_pager43 from .termui import edit as edit44-from .termui import get_terminal_size as get_terminal_size44 from .termui import getchar as getchar45 from .termui import launch as launch46 from .termui import pause as pause47 from .termui import progressbar as progressbar18 unmodified lines66 from .utils import echo as echo67 from .utils import format_filename as format_filename68 from .utils import get_app_dir as get_app_dir69 from .utils import get_binary_stream as get_binary_stream71-from .utils import get_os_args as get_os_args70 from .utils import get_text_stream as get_text_stream71 from .utils import open_file as open_file72 73 __version__ = "8.1.0.dev0"modified:src/click/core.py-46 removed
1566 unmodified lines1567 return rv1568 1569 return decorator1570 1571- def resultcallback(self, replace: bool = False) -> t.Callable[[F], F]:1572- import warnings1573-1574- 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)1581-1571 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 lines2008 [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 lines2031 self.default = default2032 self.is_eager = is_eager2033 self.metavar = metavar2034 self.envvar = envvar2051-2052- if autocompletion is not None:2053- import warnings2054-2055- 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- )2062-2063- def shell_complete(2064- ctx: Context, param: "Parameter", incomplete: str2065- ) -> t.List["CompletionItem"]:2066- from click.shell_completion import CompletionItem2067-2068- out = []2069-2070- 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)2075-2076- if c.value.startswith(incomplete):2077- out.append(c)2078-2079- return out2080-2035 self._custom_shell_complete = shell_complete2036 2037 if __debug__:2038 if self.type.is_composite and nargs != self.type.arity:876 unmodified linesmodified:src/click/termui.py-20 removed
250 unmodified lines251 raise Abort()252 return rv253 254 255-def 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.258-259- .. deprecated:: 8.0260- Will be removed in Click 8.1. Use261- :func:`shutil.get_terminal_size` instead.262- """263- import shutil264- import warnings265-266- 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()273-274-255 def 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 linesmodified:src/click/utils.py-19 removed
377 unmodified lines378 379 return f380 381 382-def 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.385-386- .. deprecated:: 8.0387- Will be removed in Click 8.1. Access ``sys.argv[1:]`` directly388- instead.389- """390- import warnings391-392- 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:]399-400-382 def 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 this184 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+9 added
4 unmodified lines5 6 Unreleased7 8 - 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+ - ``get_terminal_size`` is removed, use15+ ``shutil.get_terminal_size`` instead.16+ - ``get_os_args`` is removed, use ``sys.argv[1:]`` instead.17+18 - Single options boolean flags with ``show_default=True`` only show19 the default if it is ``True``. :issue:`1971`20 21 941 unmodified lines