summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2021-11-10 16:49:47 -0800
committerGitHub <noreply@github.com>2021-11-10 16:49:47 -0800
commit6411f425fae545f42795665af4162006b36c5e4a (patch)
treeaf6a529b01ae6a9a24b60a52c4b458a3583eec14
parent4b4e2bdab832c1e970b9acc1cd2ead101d6e0308 (diff)
parent60a5eafaf5f2a71b2a8a4f93ad1faefb2b8b0f76 (diff)
downloadclick-6411f425fae545f42795665af4162006b36c5e4a.tar.gz
Merge pull request #2130 from pallets/remove-deprecated-code
remove deprecated code
-rw-r--r--CHANGES.rst9
-rw-r--r--docs/api.rst2
-rw-r--r--src/click/__init__.py2
-rw-r--r--src/click/core.py46
-rw-r--r--src/click/termui.py20
-rw-r--r--src/click/utils.py19
-rw-r--r--tests/test_shell_completion.py14
7 files changed, 9 insertions, 103 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index eb093fd..43f1f51 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -6,6 +6,15 @@ Version 8.1.0
Unreleased
- Drop support for Python 3.6. :pr:`2129`
+- Remove previously deprecated code. :pr:`2130`
+
+ - ``Group.resultcallback`` is renamed to ``result_callback``.
+ - ``autocompletion`` parameter to ``Command`` is renamed to
+ ``shell_complete``.
+ - ``get_terminal_size`` is removed, use
+ ``shutil.get_terminal_size`` instead.
+ - ``get_os_args`` is removed, use ``sys.argv[1:]`` instead.
+
- Single options boolean flags with ``show_default=True`` only show
the default if it is ``True``. :issue:`1971`
diff --git a/docs/api.rst b/docs/api.rst
index 5133085..09efd03 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -63,8 +63,6 @@ Utilities
.. autofunction:: pause
-.. autofunction:: get_terminal_size
-
.. autofunction:: get_binary_stream
.. autofunction:: get_text_stream
diff --git a/src/click/__init__.py b/src/click/__init__.py
index 8790877..33080c0 100644
--- a/src/click/__init__.py
+++ b/src/click/__init__.py
@@ -41,7 +41,6 @@ from .termui import clear as clear
from .termui import confirm as confirm
from .termui import echo_via_pager as echo_via_pager
from .termui import edit as edit
-from .termui import get_terminal_size as get_terminal_size
from .termui import getchar as getchar
from .termui import launch as launch
from .termui import pause as pause
@@ -68,7 +67,6 @@ from .utils import echo as echo
from .utils import format_filename as format_filename
from .utils import get_app_dir as get_app_dir
from .utils import get_binary_stream as get_binary_stream
-from .utils import get_os_args as get_os_args
from .utils import get_text_stream as get_text_stream
from .utils import open_file as open_file
diff --git a/src/click/core.py b/src/click/core.py
index 5a4129c..ba6877b 100644
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -1568,17 +1568,6 @@ class MultiCommand(Command):
return decorator
- def resultcallback(self, replace: bool = False) -> t.Callable[[F], F]:
- import warnings
-
- warnings.warn(
- "'resultcallback' has been renamed to 'result_callback'."
- " The old name will be removed in Click 8.1.",
- DeprecationWarning,
- stacklevel=2,
- )
- return self.result_callback(replace=replace)
-
def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None:
"""Extra format methods for multi methods that adds all the commands
after the options.
@@ -2020,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
@@ -2048,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/src/click/termui.py b/src/click/termui.py
index cf8d5f1..19dced0 100644
--- a/src/click/termui.py
+++ b/src/click/termui.py
@@ -252,26 +252,6 @@ def confirm(
return rv
-def get_terminal_size() -> os.terminal_size:
- """Returns the current size of the terminal as tuple in the form
- ``(width, height)`` in columns and rows.
-
- .. deprecated:: 8.0
- Will be removed in Click 8.1. Use
- :func:`shutil.get_terminal_size` instead.
- """
- import shutil
- import warnings
-
- warnings.warn(
- "'click.get_terminal_size()' is deprecated and will be removed"
- " in Click 8.1. Use 'shutil.get_terminal_size()' instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return shutil.get_terminal_size()
-
-
def echo_via_pager(
text_or_generator: t.Union[t.Iterable[str], t.Callable[[], t.Iterable[str]], str],
color: t.Optional[bool] = None,
diff --git a/src/click/utils.py b/src/click/utils.py
index 051cf70..03fbaa7 100644
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -379,25 +379,6 @@ def open_file(
return f
-def get_os_args() -> t.Sequence[str]:
- """Returns the argument part of ``sys.argv``, removing the first
- value which is the name of the script.
-
- .. deprecated:: 8.0
- Will be removed in Click 8.1. Access ``sys.argv[1:]`` directly
- instead.
- """
- import warnings
-
- warnings.warn(
- "'get_os_args' is deprecated and will be removed in Click 8.1."
- " Access 'sys.argv[1:]' directly instead.",
- DeprecationWarning,
- stacklevel=2,
- )
- return sys.argv[1:]
-
-
def format_filename(
filename: t.Union[str, bytes, os.PathLike], shorten: bool = False
) -> str:
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",