diff options
| author | David Lord <davidism@gmail.com> | 2020-04-19 22:16:48 -0700 |
|---|---|---|
| committer | David Lord <davidism@gmail.com> | 2020-04-19 23:58:30 -0700 |
| commit | 56921211a3bdaefcc664994139979d25281167cf (patch) | |
| tree | 3df16ddcbd4e8dd9e9eb17a370c0483e2bc95529 /src | |
| parent | 20fddf68e85ca98eff368aa171965754f9f446b5 (diff) | |
| download | click-56921211a3bdaefcc664994139979d25281167cf.tar.gz | |
remove more compat code
Diffstat (limited to 'src')
| -rw-r--r-- | src/click/_bashcomplete.py | 6 | ||||
| -rw-r--r-- | src/click/_termui_impl.py | 3 | ||||
| -rw-r--r-- | src/click/_winconsole.py | 6 | ||||
| -rw-r--r-- | src/click/termui.py | 12 | ||||
| -rw-r--r-- | src/click/testing.py | 8 | ||||
| -rw-r--r-- | src/click/types.py | 9 | ||||
| -rw-r--r-- | src/click/utils.py | 9 |
7 files changed, 18 insertions, 35 deletions
diff --git a/src/click/_bashcomplete.py b/src/click/_bashcomplete.py index cbabd8d..9e963f7 100644 --- a/src/click/_bashcomplete.py +++ b/src/click/_bashcomplete.py @@ -1,6 +1,7 @@ import copy import os import re +from collections import abc from .core import Argument from .core import MultiCommand @@ -9,11 +10,6 @@ from .parser import split_arg_string from .types import Choice from .utils import echo -try: - from collections import abc -except ImportError: - import collections as abc - WORDBREAK = "=" # Note, only BASH version 4.4 and later have the nosort option. diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py index 1a6adf1..2ea695e 100644 --- a/src/click/_termui_impl.py +++ b/src/click/_termui_impl.py @@ -125,9 +125,6 @@ class ProgressBar(object): # twice works and does "what you want". return next(iter(self)) - # Python 2 compat - next = __next__ - def is_fast(self): return time.time() - self.start <= self.short_limit diff --git a/src/click/_winconsole.py b/src/click/_winconsole.py index 18310ad..5a3cdaa 100644 --- a/src/click/_winconsole.py +++ b/src/click/_winconsole.py @@ -32,11 +32,11 @@ from ._compat import _NonClosingTextIOWrapper try: from ctypes import pythonapi - - PyObject_GetBuffer = pythonapi.PyObject_GetBuffer - PyBuffer_Release = pythonapi.PyBuffer_Release except ImportError: pythonapi = None +else: + PyObject_GetBuffer = pythonapi.PyObject_GetBuffer + PyBuffer_Release = pythonapi.PyBuffer_Release c_ssize_p = POINTER(c_ssize_t) diff --git a/src/click/termui.py b/src/click/termui.py index 73f35f5..dd51cdf 100644 --- a/src/click/termui.py +++ b/src/click/termui.py @@ -216,14 +216,10 @@ def get_terminal_size(): """Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows. """ - # If shutil has get_terminal_size() (Python 3.3 and later) use that - if sys.version_info >= (3, 3): - import shutil - - shutil_get_terminal_size = getattr(shutil, "get_terminal_size", None) - if shutil_get_terminal_size: - sz = shutil_get_terminal_size() - return sz.columns, sz.lines + import shutil + + if hasattr(shutil, "get_terminal_size"): + return shutil.get_terminal_size() # We provide a sensible default for get_winterm_size() when being invoked # inside a subprocess. Without this, it would not provide a useful input. diff --git a/src/click/testing.py b/src/click/testing.py index 9c3c012..eef3399 100644 --- a/src/click/testing.py +++ b/src/click/testing.py @@ -110,9 +110,7 @@ class CliRunner(object): works in single-threaded systems without any concurrency as it changes the global interpreter state. - :param charset: the character set for the input and output data. This is - UTF-8 by default and should not be changed currently as - the reporting to Click only works in Python 2 properly. + :param charset: the character set for the input and output data. :param env: a dictionary with environment variables for overriding. :param echo_stdin: if this is set to `True`, then reading from stdin writes to stdout. This is useful for showing examples in @@ -125,9 +123,7 @@ class CliRunner(object): independently """ - def __init__(self, charset=None, env=None, echo_stdin=False, mix_stderr=True): - if charset is None: - charset = "utf-8" + def __init__(self, charset="utf-8", env=None, echo_stdin=False, mix_stderr=True): self.charset = charset self.env = env or {} self.echo_stdin = echo_stdin diff --git a/src/click/types.py b/src/click/types.py index 5647df5..d794235 100644 --- a/src/click/types.py +++ b/src/click/types.py @@ -721,11 +721,10 @@ def convert_type(ty, default=None): #: A dummy parameter type that just does nothing. From a user's -#: perspective this appears to just be the same as `STRING` but internally -#: no string conversion takes place. This is necessary to achieve the -#: same bytes/unicode behavior on Python 2/3 in situations where you want -#: to not convert argument types. This is usually useful when working -#: with file paths as they can appear in bytes and unicode. +#: perspective this appears to just be the same as `STRING` but +#: internally no string conversion takes place if the input was bytes. +#: This is usually useful when working with file paths as they can +#: appear in bytes and unicode. #: #: For path related uses the :class:`Path` type is a better choice but #: there are situations where an unprocessed type is useful which is why diff --git a/src/click/utils.py b/src/click/utils.py index f5aac49..0f634bb 100644 --- a/src/click/utils.py +++ b/src/click/utils.py @@ -232,11 +232,10 @@ def echo(message=None, file=None, nl=True, err=False, color=None): else: message += b"\n" - # If there is a message, and we're in Python 3, and the value looks - # like bytes, we manually need to find the binary stream and write the - # message in there. This is done separately so that most stream - # types will work as you would expect. Eg: you can write to StringIO - # for other cases. + # If there is a message and the value looks like bytes, we manually + # need to find the binary stream and write the message in there. + # This is done separately so that most stream types will work as you + # would expect. Eg: you can write to StringIO for other cases. if message and is_bytes(message): binary_file = _find_binary_writer(file) if binary_file is not None: |
