apply reorder-python-imports
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 c781282 · Browse files · 37 files·+254 added−188 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
37 files+254 added−188 removed
- tests:+27 added−21 removed
- other:+227 added−167 removed
Provenance
- Commit
488739d- Tree
3fff5ef- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
c781282
37 files changed+254 added−188 removed
modified:examples/aliases/aliases.py+3 added-2 removed
1 import os2+3 import click4 5 try:5- import ConfigParser as configparser6-except ImportError:6 import configparser7+except ImportError:8+ import ConfigParser as configparser9 10 11 class Config(object):12 """The config in this example only holds aliases."""124 unmodified linesmodified:examples/bashcompletion/bashcompletion.py+2 added-1 removed
1-import click1 import os2 3+import click4 5+6 @click.group()7 def cli():8 pass9 37 unmodified linesmodified:examples/complex/complex/commands/cmd_init.py+2 added-1 removed
1-import click1 from complex.cli import pass_environment2 3+import click4 5+6 @click.command('init', short_help='Initializes a repo.')7 @click.argument('path', required=False, type=click.Path(resolve_path=True))8 @pass_environment9 def cli(ctx, path):5 unmodified linesmodified:examples/complex/complex/commands/cmd_status.py+2 added-1 removed
1-import click1 from complex.cli import pass_environment2 3+import click4 5+6 @click.command('status', short_help='Shows file changes.')7 @pass_environment8 def cli(ctx):9 """Shows file changes in the current working directory."""2 unmodified linesmodified:examples/complex/complex/cli.py+1 added
1 import os2 import sys3+4 import click5 6 7 CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')59 unmodified linesmodified:examples/imagepipe/imagepipe.py+6 added-2 removed
1-import click1 from functools import update_wrapper3-from PIL import Image, ImageFilter, ImageEnhance2 3+from PIL import Image4+from PIL import ImageEnhance5+from PIL import ImageFilter6 7+import click8+9+10 @click.group(chain=True)11 def cli():12 """This script processes a bunch of images through pillow in a unix13 pipe. One commands feeds into the next.257 unmodified linesmodified:examples/repo/repo.py+1 added-1 removed
1 import os2-import sys2 import posixpath3+import sys4 5 import click6 7 144 unmodified linesmodified:examples/termui/termui.py+4 added-8 removed
1 # coding: utf-82-import click2 import math4-import time3 import random4+import time5 7-try:8- range_type = xrange9-except NameError:10- range_type = range6+import click7 8 9 @click.group()10 def cli():12 unmodified lines23 @cli.command()24 def pager():25 """Demonstrates using the pager."""26 lines = []31- for x in range_type(200):27+ for x in range(200):28 lines.append('%s. Hello World!' % click.style(str(x), fg='green'))29 click.echo_via_pager('\n'.join(lines))30 31 1 unmodified line33 @click.option('--count', default=8000, type=click.IntRange(1, 100000),34 help='The number of items to process.')35 def progress(count):36 """Demonstrates the progress bar."""41- items = range_type(count)37+ items = range(count)38 39 def process_slowly(item):40 time.sleep(0.002 * random.random())41 111 unmodified linesmodified:examples/validation/validation.py+1 added
1 import click2+3 try:4 from urllib import parse as urlparse5 except ImportError:6 import urlparse39 unmodified linesmodified:src/click/__init__.py+65 added-77 removed
1-# -*- coding: utf-8 -*-1 """2 Click is a simple Python module inspired by the stdlib optparse to make3 writing command line scripts fun. Unlike other modules, it's based4 around a simple API that does not come with too much magic and is5 composable.6 """8-9-# Core classes10-from .core import Context, BaseCommand, Command, MultiCommand, Group, \11- CommandCollection, Parameter, Option, Argument12-13-# Globals7+from .core import Argument8+from .core import BaseCommand9+from .core import Command10+from .core import CommandCollection11+from .core import Context12+from .core import Group13+from .core import MultiCommand14+from .core import Option15+from .core import Parameter16+from .decorators import argument17+from .decorators import command18+from .decorators import confirmation_option19+from .decorators import group20+from .decorators import help_option21+from .decorators import make_pass_decorator22+from .decorators import option23+from .decorators import pass_context24+from .decorators import pass_obj25+from .decorators import password_option26+from .decorators import version_option27+from .exceptions import Abort28+from .exceptions import BadArgumentUsage29+from .exceptions import BadOptionUsage30+from .exceptions import BadParameter31+from .exceptions import ClickException32+from .exceptions import FileError33+from .exceptions import MissingParameter34+from .exceptions import NoSuchOption35+from .exceptions import UsageError36+from .formatting import HelpFormatter37+from .formatting import wrap_text38 from .globals import get_current_context15-16-# Decorators17-from .decorators import pass_context, pass_obj, make_pass_decorator, \18- command, group, argument, option, confirmation_option, \19- password_option, version_option, help_option20-21-# Types22-from .types import ParamType, File, Path, Choice, IntRange, Tuple, \23- DateTime, STRING, INT, FLOAT, BOOL, UUID, UNPROCESSED, FloatRange24-25-# Utilities26-from .utils import echo, get_binary_stream, get_text_stream, open_file, \27- format_filename, get_app_dir, get_os_args28-29-# Terminal functions30-from .termui import prompt, confirm, get_terminal_size, echo_via_pager, \31- progressbar, clear, style, unstyle, secho, edit, launch, getchar, \32- pause33-34-# Exceptions35-from .exceptions import ClickException, UsageError, BadParameter, \36- FileError, Abort, NoSuchOption, BadOptionUsage, BadArgumentUsage, \37- MissingParameter38-39-# Formatting40-from .formatting import HelpFormatter, wrap_text41-42-# Parsing39 from .parser import OptionParser40+from .termui import clear41+from .termui import confirm42+from .termui import echo_via_pager43+from .termui import edit44+from .termui import get_terminal_size45+from .termui import getchar46+from .termui import launch47+from .termui import pause48+from .termui import progressbar49+from .termui import prompt50+from .termui import secho51+from .termui import style52+from .termui import unstyle53+from .types import BOOL54+from .types import Choice55+from .types import DateTime56+from .types import File57+from .types import FLOAT58+from .types import FloatRange59+from .types import INT60+from .types import IntRange61+from .types import ParamType62+from .types import Path63+from .types import STRING64+from .types import Tuple65+from .types import UNPROCESSED66+from .types import UUID67+from .utils import echo68+from .utils import format_filename69+from .utils import get_app_dir70+from .utils import get_binary_stream71+from .utils import get_os_args72+from .utils import get_text_stream73+from .utils import open_file74 45-46-__all__ = [47- # Core classes48- 'Context', 'BaseCommand', 'Command', 'MultiCommand', 'Group',49- 'CommandCollection', 'Parameter', 'Option', 'Argument',50-51- # Globals52- 'get_current_context',53-54- # Decorators55- 'pass_context', 'pass_obj', 'make_pass_decorator', 'command', 'group',56- 'argument', 'option', 'confirmation_option', 'password_option',57- 'version_option', 'help_option',58-59- # Types60- 'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'Tuple',61- 'DateTime', 'STRING', 'INT', 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED',62- 'FloatRange',63-64- # Utilities65- 'echo', 'get_binary_stream', 'get_text_stream', 'open_file',66- 'format_filename', 'get_app_dir', 'get_os_args',67-68- # Terminal functions69- 'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager',70- 'progressbar', 'clear', 'style', 'unstyle', 'secho', 'edit', 'launch',71- 'getchar', 'pause',72-73- # Exceptions74- 'ClickException', 'UsageError', 'BadParameter', 'FileError',75- 'Abort', 'NoSuchOption', 'BadOptionUsage', 'BadArgumentUsage',76- 'MissingParameter',77-78- # Formatting79- 'HelpFormatter', 'wrap_text',80-81- # Parsing82- 'OptionParser',83-]84-85-75 # Controls if click should emit the warning about the use of unicode76 # literals.77 disable_unicode_literals_warning = False78 90-79 __version__ = '7.1.dev'modified:src/click/_bashcomplete.py+4 added-2 removed
1 import copy2 import os3 import re4 5-from .utils import echo5+from .core import Argument6+from .core import MultiCommand7+from .core import Option8 from .parser import split_arg_string7-from .core import MultiCommand, Option, Argument9 from .types import Choice10+from .utils import echo11 12 try:13 from collections import abc14 except ImportError:322 unmodified linesmodified:src/click/_compat.py+2 added-3 removed
1-import re1+import codecs2 import io3 import os4+import re5 import sys5-import codecs6 from weakref import WeakKeyDictionary7 8-8 PY2 = sys.version_info[0] == 29 CYGWIN = sys.platform.startswith('cygwin')10 MSYS2 = sys.platform.startswith('win') and ('GCC' in sys.version)11 # Determine local App Engine environment, per Google's own suggestion762 unmodified linesmodified:src/click/_termui_impl.py+15 added-8 removed
2 unmodified lines3 This module contains implementations for the termui module. To keep the4 import time of Click down, some infrequently used functionality is5 placed in this module and only imported as needed.6 """7-7+import contextlib8+import math9 import os10 import sys11 import time11-import math12-import contextlib13-from ._compat import _default_text_stdout, range_type, isatty, \14- open_stream, shlex_quote, strip_ansi, term_len, get_best_encoding, WIN, \15- int_types, CYGWIN16-from .utils import echo12+13+from ._compat import _default_text_stdout14+from ._compat import CYGWIN15+from ._compat import get_best_encoding16+from ._compat import int_types17+from ._compat import isatty18+from ._compat import open_stream19+from ._compat import range_type20+from ._compat import shlex_quote21+from ._compat import strip_ansi22+from ._compat import term_len23+from ._compat import WIN24 from .exceptions import ClickException25+from .utils import echo26 19-27 if os.name == 'nt':28 BEFORE_BAR = '\r'29 AFTER_BAR = '\n'30 else:609 unmodified linesmodified:src/click/_unicodefun.py+1 added-2 removed
1+import codecs2 import os3 import sys3-import codecs4 5 from ._compat import PY26 7-7 # If someone wants to vendor click, we want to ensure the8 # correct package is discovered. Ideally we could use a9 # relative import here but unfortunately Python does not10 # support that.114 unmodified linesmodified:src/click/_winconsole.py+24 added-8 removed
5 unmodified lines6 # There are some general differences in regards to how this works7 # compared to the original patches as we do not need to patch8 # the entire interpreter but just work in our little world of9 # echo and prmopt.10-10+import ctypes11 import io12 import os13 import sys14-import zlib14 import time16-import ctypes15+import zlib16+from ctypes import byref17+from ctypes import c_char18+from ctypes import c_char_p19+from ctypes import c_int20+from ctypes import c_ssize_t21+from ctypes import c_ulong22+from ctypes import c_void_p23+from ctypes import POINTER24+from ctypes import py_object25+from ctypes import windll26+from ctypes import WinError27+from ctypes import WINFUNCTYPE28+from ctypes.wintypes import DWORD29+from ctypes.wintypes import HANDLE30+from ctypes.wintypes import LPCWSTR31+from ctypes.wintypes import LPWSTR32+33 import msvcrt18-from ._compat import _NonClosingTextIOWrapper, text_type, PY219-from ctypes import byref, POINTER, c_int, c_char, c_char_p, \20- c_void_p, py_object, c_ssize_t, c_ulong, windll, WINFUNCTYPE, \21- WinError34+35+from ._compat import _NonClosingTextIOWrapper36+from ._compat import PY237+from ._compat import text_type38+39 try:40 from ctypes import pythonapi41 PyObject_GetBuffer = pythonapi.PyObject_GetBuffer42 PyBuffer_Release = pythonapi.PyBuffer_Release43 except ImportError:44 pythonapi = None28-from ctypes.wintypes import DWORD, LPWSTR, LPCWSTR, HANDLE45 46 47 c_ssize_p = POINTER(c_ssize_t)48 298 unmodified linesmodified:src/click/core.py+30 added-15 removed
1 unmodified line2 import inspect3 import os4 import sys5 from contextlib import contextmanager6-from itertools import repeat6 from functools import update_wrapper7+from itertools import repeat8 9-from .types import convert_type, IntRange, BOOL10-from .utils import PacifyFlushWrapper, make_str, make_default_short_help, \11- echo, get_os_args12-from .exceptions import ClickException, UsageError, BadParameter, Abort, \13- MissingParameter, Exit14-from .termui import prompt, confirm, style15-from .formatting import HelpFormatter, join_options16-from .parser import OptionParser, split_opt17-from .globals import push_context, pop_context9+from ._compat import isidentifier10+from ._compat import iteritems11+from ._compat import PY212+from ._compat import string_types13+from ._unicodefun import _check_for_unicode_literals14+from ._unicodefun import _verify_python3_env15+from .exceptions import Abort16+from .exceptions import BadParameter17+from .exceptions import ClickException18+from .exceptions import Exit19+from .exceptions import MissingParameter20+from .exceptions import UsageError21+from .formatting import HelpFormatter22+from .formatting import join_options23+from .globals import pop_context24+from .globals import push_context25+from .parser import OptionParser26+from .parser import split_opt27+from .termui import confirm28+from .termui import prompt29+from .termui import style30+from .types import BOOL31+from .types import convert_type32+from .types import IntRange33+from .utils import echo34+from .utils import get_os_args35+from .utils import make_default_short_help36+from .utils import make_str37+from .utils import PacifyFlushWrapper38 19-from ._compat import PY2, isidentifier, iteritems, string_types20-from ._unicodefun import _check_for_unicode_literals, _verify_python3_env21-22-39 _missing = object()40 25-41 SUBCOMMAND_METAVAR = 'COMMAND [ARGS]...'42 SUBCOMMANDS_METAVAR = 'COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...'43 44 DEPRECATED_HELP_NOTICE = ' (DEPRECATED)'1872 unmodified linesmodified:src/click/decorators.py+2 added-3 removed
1-import sys1 import inspect3-2+import sys3 from functools import update_wrapper4 5 from ._compat import iteritems6 from ._unicodefun import _check_for_unicode_literals8-from .utils import echo7 from .globals import get_current_context8+from .utils import echo9 10 11 def pass_context(f):12 """Marks a callback as wanting to receive the current context298 unmodified linesmodified:src/click/exceptions.py+3 added-1 removed
1-from ._compat import PY2, filename_to_ui, get_text_stderr1+from ._compat import filename_to_ui2+from ._compat import get_text_stderr3+from ._compat import PY24 from .utils import echo5 6 7 def _join_param_hints(param_hint):243 unmodified linesmodified:src/click/formatting.py+3 added-3 removed
1 from contextlib import contextmanager2-from .termui import get_terminal_size3-from .parser import split_opt2+3 from ._compat import term_len4+from .parser import split_opt5+from .termui import get_terminal_size6 6-7 # Can force a width. This is used by the test system8 FORCED_WIDTH = None9 10 252 unmodified linesmodified:src/click/globals.py-1 removed
1 from threading import local2 3-3 _local = local()4 5 6 def get_current_context(silent=False):41 unmodified linesmodified:src/click/parser.py+5 added-3 removed
16 unmodified lines17 18 Copyright 2001-2006 Gregory P. Ward. All rights reserved.19 Copyright 2002-2006 Python Software Foundation. All rights reserved.20 """21-21 import re22 from collections import deque24-from .exceptions import UsageError, NoSuchOption, BadOptionUsage, \25- BadArgumentUsage23 24+from .exceptions import BadArgumentUsage25+from .exceptions import BadOptionUsage26+from .exceptions import NoSuchOption27+from .exceptions import UsageError28 29+30 def _unpack_args(args, nargs_spec):31 """Given an iterable of arguments and an iterable of nargs specifications,32 it returns a tuple with all the unpacked arguments at the first index33 and all remaining arguments as the second.399 unmodified linesmodified:src/click/termui.py+17 added-9 removed
1+import inspect2 import io3+import itertools4 import os3-import sys5 import struct5-import inspect6-import itertools6+import sys7 8-from ._compat import raw_input, text_type, string_types, \9- isatty, strip_ansi, get_winterm_size, DEFAULT_COLUMNS, WIN10-from .utils import echo11-from .exceptions import Abort, UsageError12-from .types import convert_type, Choice, Path8+from ._compat import DEFAULT_COLUMNS9+from ._compat import get_winterm_size10+from ._compat import isatty11+from ._compat import raw_input12+from ._compat import string_types13+from ._compat import strip_ansi14+from ._compat import text_type15+from ._compat import WIN16+from .exceptions import Abort17+from .exceptions import UsageError18 from .globals import resolve_color_default19+from .types import Choice20+from .types import convert_type21+from .types import Path22+from .utils import echo23 from .utils import LazyFile24 16-25 # The prompt functions to use. The doc tools currently override these26 # functions to customize how they work.27 visible_prompt_func = raw_input28 601 unmodified linesmodified:src/click/testing.py+6 added-5 removed
1+import contextlib2 import os2-import sys3+import shlex4 import shutil5+import sys6 import tempfile5-import contextlib6-import shlex7 8-from ._compat import iteritems, PY2, string_types8+from ._compat import iteritems9+from ._compat import PY210+from ._compat import string_types11 10-12 # If someone wants to vendor click, we want to ensure the13 # correct package is discovered. Ideally we could use a14 # relative import here but unfortunately Python does not15 # support that.363 unmodified linesmodified:src/click/types.py+9 added-3 removed
1 import os2 import stat3 from datetime import datetime4 5-from ._compat import open_stream, text_type, filename_to_ui, \6- get_filesystem_encoding, get_streerror, _get_argv_encoding, PY25+from ._compat import _get_argv_encoding6+from ._compat import filename_to_ui7+from ._compat import get_filesystem_encoding8+from ._compat import get_streerror9+from ._compat import open_stream10+from ._compat import PY211+from ._compat import text_type12 from .exceptions import BadParameter8-from .utils import safecall, LazyFile13+from .utils import LazyFile14+from .utils import safecall15 16 17 class ParamType(object):18 """Helper for converting values through types. The following is667 unmodified linesmodified:src/click/utils.py+19 added-8 removed
1 import os2 import sys3 4+from ._compat import _default_text_stderr5+from ._compat import _default_text_stdout6+from ._compat import auto_wrap_for_ansi7+from ._compat import binary_streams8+from ._compat import filename_to_ui9+from ._compat import get_filesystem_encoding10+from ._compat import get_streerror11+from ._compat import is_bytes12+from ._compat import open_stream13+from ._compat import PY214+from ._compat import should_strip_ansi15+from ._compat import string_types16+from ._compat import strip_ansi17+from ._compat import text_streams18+from ._compat import text_type19+from ._compat import WIN20 from .globals import resolve_color_default21 6-from ._compat import text_type, open_stream, get_filesystem_encoding, \7- get_streerror, string_types, PY2, binary_streams, text_streams, \8- filename_to_ui, auto_wrap_for_ansi, strip_ansi, should_strip_ansi, \9- _default_text_stdout, _default_text_stderr, is_bytes, WIN10-22 if not PY2:23 from ._compat import _find_binary_writer24 elif WIN:14- from ._winconsole import _get_windows_argv, \15- _hash_py_argv, _initial_argv_hash25+ from ._winconsole import _get_windows_argv26+ from ._winconsole import _hash_py_argv27+ from ._winconsole import _initial_argv_hash28 17-29 echo_native_types = string_types + (bytes, bytearray)30 31 32 def _posixify(name):419 unmodified linesmodified:tests/conftest.py+2 added-2 removed
1-from click.testing import CliRunner2-1 import pytest2 3+from click.testing import CliRunner4 5+6 @pytest.fixture(scope='function')7 def runner(request):8 return CliRunner()modified:tests/test_arguments.py+5 added-2 removed
1 # -*- coding: utf-8 -*-2+import sys3+4 import pytest5+6 import click4-import sys5-from click._compat import PY2, text_type7+from click._compat import PY28+from click._compat import text_type9 10 11 def test_nargs_star(runner):12 @click.command()319 unmodified linesmodified:tests/test_bashcomplete.py-1 removed
1 # -*- coding: utf-8 -*-2-2 import pytest3 4 import click5 from click._bashcomplete import get_choices430 unmodified linesmodified:tests/test_basic.py+1 added
1 # -*- coding: utf-8 -*-2 import os3 import uuid4+5 import click6 7 8 def test_basic_functionality(runner):547 unmodified linesmodified:tests/test_chain.py+3 added-1 removed
1 import sys2-import click2+3 import pytest4 5+import click6 7+8 def debug():9 click.echo('%s=%s' % (10 sys._getframe(1).f_code.co_name,11 '|'.join(click.get_current_context().args),243 unmodified linesmodified:tests/test_commands.py-1 removed
1 # -*- coding: utf-8 -*-2 import re3 4 import click5-import pytest5 6 7 def test_other_command_invoke(runner):8 @click.command()284 unmodified linesmodified:tests/test_compat.py+4 added-2 removed
1-import click1 import pytest3-from click._compat import should_strip_ansi, WIN2 3+import click4+from click._compat import should_strip_ansi5+from click._compat import WIN6 7+8 def test_legacy_callbacks(runner):9 def legacy_callback(ctx, value):10 return value.upper()11 34 unmodified linesmodified:tests/test_imports.py+1 added-1 removed
1-import sys1 import json2 import subprocess3+import sys4 5 from click._compat import WIN6 7 48 unmodified linesmodified:tests/test_options.py+3 added-2 removed
1 # -*- coding: utf-8 -*-2-import re2 import os4-import click3+import re4+5 import pytest6 7+import click8 from click._compat import text_type9 10 11 def test_prefixes(runner):546 unmodified linesmodified:tests/test_termui.py+2 added-3 removed
1 # -*- coding: utf-8 -*-2-import pytest3-4-import click2 import time3 4+import pytest5+6 import click._termui_impl7 from click._compat import WIN8 9 303 unmodified linesmodified:tests/test_testing.py+3 added-3 removed
1 import os2 import sys3 4 import pytest5-import click5 6+import click7+from click._compat import PY28+from click._compat import WIN9 from click.testing import CliRunner10 9-from click._compat import PY2, WIN10-11 # Use the most reasonable io that users would use for the python version.12 if PY2:13 from cStringIO import StringIO as ReasonableBytesIO14 else:287 unmodified linesmodified:tests/test_utils.py+3 added-3 removed
2 unmodified lines3 import sys4 5 import pytest6 7-import click8-import click.utils7 import click._termui_impl8+import click.utils10-from click._compat import WIN, PY29+from click._compat import PY210+from click._compat import WIN11 12 13 def test_echo(runner):14 with runner.isolation() as outstreams:385 unmodified lines