diff options
author | Eric Lin <anselor@gmail.com> | 2021-01-05 11:29:39 -0500 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2021-01-21 10:24:08 -0500 |
commit | f1f76a4ba207d802f78277d0ba3defa44cf7b973 (patch) | |
tree | 0a59103b35e9160aed2466fdafa0f8020c426bcc | |
parent | e0dee46ca871e56523059b1566577ff781f6fb63 (diff) | |
download | cmd2-git-import_wrapping.tar.gz |
Changed isort to force wrapping of imports to reduce merge conflicts from minor import changes.import_wrapping
69 files changed, 668 insertions, 182 deletions
diff --git a/cmd2/ansi.py b/cmd2/ansi.py index f172b87f..2a3ed01e 100644 --- a/cmd2/ansi.py +++ b/cmd2/ansi.py @@ -5,12 +5,25 @@ setting the window title, and asynchronous alerts. """ import functools import re -from enum import Enum -from typing import IO, Any, List, Union +from enum import ( + Enum, +) +from typing import ( + IO, + Any, + List, + Union, +) import colorama -from colorama import Back, Fore, Style -from wcwidth import wcswidth +from colorama import ( + Back, + Fore, + Style, +) +from wcwidth import ( + wcswidth, +) # On Windows, filter ANSI escape codes out of text sent to stdout/stderr, and replace them with equivalent Win32 calls colorama.init(strip=False) diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 117bfd50..9f4a70d3 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -10,10 +10,21 @@ import argparse import inspect import numbers import shutil -from collections import deque -from typing import Dict, List, Optional, Union +from collections import ( + deque, +) +from typing import ( + Dict, + List, + Optional, + Union, +) -from . import ansi, cmd2, constants +from . import ( + ansi, + cmd2, + constants, +) from .argparse_custom import ( ATTR_CHOICES_CALLABLE, ATTR_DESCRIPTIVE_COMPLETION_HEADER, @@ -23,9 +34,17 @@ from .argparse_custom import ( CompletionItem, generate_range_error, ) -from .command_definition import CommandSet -from .table_creator import Column, SimpleTable -from .utils import CompletionError, basic_complete +from .command_definition import ( + CommandSet, +) +from .table_creator import ( + Column, + SimpleTable, +) +from .utils import ( + CompletionError, + basic_complete, +) # If no descriptive header is supplied, then this will be used instead DEFAULT_DESCRIPTIVE_HEADER = 'Description' diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index d773f851..ae60d09e 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -220,10 +220,25 @@ import argparse import re import sys # noinspection PyUnresolvedReferences,PyProtectedMember -from argparse import ONE_OR_MORE, ZERO_OR_MORE, ArgumentError, _ -from typing import Any, Callable, Optional, Tuple, Type, Union - -from . import ansi, constants +from argparse import ( + ONE_OR_MORE, + ZERO_OR_MORE, + ArgumentError, + _, +) +from typing import ( + Any, + Callable, + Optional, + Tuple, + Type, + Union, +) + +from . import ( + ansi, + constants, +) ############################################################################################################ # The following are names of custom argparse argument attributes added by cmd2 diff --git a/cmd2/clipboard.py b/cmd2/clipboard.py index deb2f5cc..c759d8da 100644 --- a/cmd2/clipboard.py +++ b/cmd2/clipboard.py @@ -4,7 +4,9 @@ This module provides basic ability to copy from and paste to the clipboard/paste """ import pyperclip # noinspection PyProtectedMember -from pyperclip import PyperclipException +from pyperclip import ( + PyperclipException, +) # Can we access the clipboard? Should always be true on Windows and Mac, but only sometimes on Linux try: diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index c8f5a9bd..689f81a5 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -38,29 +38,89 @@ import pydoc import re import sys import threading -from code import InteractiveConsole -from collections import namedtuple -from contextlib import redirect_stdout -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union - -from . import ansi, constants, plugin, utils -from .argparse_custom import DEFAULT_ARGUMENT_PARSER, CompletionItem -from .clipboard import can_clip, get_paste_buffer, write_to_paste_buffer -from .command_definition import CommandSet -from .constants import CLASS_ATTR_DEFAULT_HELP_CATEGORY, COMMAND_FUNC_PREFIX, COMPLETER_FUNC_PREFIX, HELP_FUNC_PREFIX -from .decorators import with_argparser, as_subcommand_to +from code import ( + InteractiveConsole, +) +from collections import ( + namedtuple, +) +from contextlib import ( + redirect_stdout, +) +from typing import ( + Any, + Callable, + Dict, + Iterable, + List, + Mapping, + Optional, + Tuple, + Type, + Union, +) + +from . import ( + ansi, + constants, + plugin, + utils, +) +from .argparse_custom import ( + DEFAULT_ARGUMENT_PARSER, + CompletionItem, +) +from .clipboard import ( + can_clip, + get_paste_buffer, + write_to_paste_buffer, +) +from .command_definition import ( + CommandSet, +) +from .constants import ( + CLASS_ATTR_DEFAULT_HELP_CATEGORY, + COMMAND_FUNC_PREFIX, + COMPLETER_FUNC_PREFIX, + HELP_FUNC_PREFIX, +) +from .decorators import ( + as_subcommand_to, + with_argparser, +) from .exceptions import ( - CommandSetRegistrationError, Cmd2ShlexError, + CommandSetRegistrationError, EmbeddedConsoleExit, EmptyStatement, RedirectionError, - SkipPostcommandHooks + SkipPostcommandHooks, +) +from .history import ( + History, + HistoryItem, +) +from .parsing import ( + Macro, + MacroArg, + Statement, + StatementParser, + shlex_split, +) +from .rl_utils import ( + RlType, + rl_get_point, + rl_make_safe_prompt, + rl_set_prompt, + rl_type, + rl_warning, + vt100_support, +) +from .utils import ( + CompletionError, + Settable, + get_defining_class, ) -from .history import History, HistoryItem -from .parsing import Macro, MacroArg, Statement, StatementParser, shlex_split -from .rl_utils import RlType, rl_get_point, rl_make_safe_prompt, rl_set_prompt, rl_type, rl_warning, vt100_support -from .utils import CompletionError, get_defining_class, Settable # Set up readline if rl_type == RlType.NONE: # pragma: no cover diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py index 3f05792c..c85814d7 100644 --- a/cmd2/command_definition.py +++ b/cmd2/command_definition.py @@ -2,10 +2,18 @@ """ Supports the definition of commands in separate classes to be composed into cmd2.Cmd """ -from typing import Optional, Type - -from .constants import CLASS_ATTR_DEFAULT_HELP_CATEGORY, COMMAND_FUNC_PREFIX -from .exceptions import CommandSetRegistrationError +from typing import ( + Optional, + Type, +) + +from .constants import ( + CLASS_ATTR_DEFAULT_HELP_CATEGORY, + COMMAND_FUNC_PREFIX, +) +from .exceptions import ( + CommandSetRegistrationError, +) # Allows IDEs to resolve types without impacting imports at runtime, breaking circular dependency issues try: # pragma: no cover diff --git a/cmd2/decorators.py b/cmd2/decorators.py index 4ee61754..c498550d 100644 --- a/cmd2/decorators.py +++ b/cmd2/decorators.py @@ -1,12 +1,30 @@ # coding=utf-8 """Decorators for ``cmd2`` commands""" import argparse -from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Union - -from . import constants -from .argparse_custom import Cmd2AttributeWrapper -from .exceptions import Cmd2ArgparseError -from .parsing import Statement +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + Iterable, + List, + Optional, + Tuple, + Union, +) + +from . import ( + constants, +) +from .argparse_custom import ( + Cmd2AttributeWrapper, +) +from .exceptions import ( + Cmd2ArgparseError, +) +from .parsing import ( + Statement, +) if TYPE_CHECKING: # pragma: no cover import cmd2 diff --git a/cmd2/history.py b/cmd2/history.py index 60a071fb..fc1691b4 100644 --- a/cmd2/history.py +++ b/cmd2/history.py @@ -4,12 +4,19 @@ History management classes """ import re -from typing import List, Union +from typing import ( + List, + Union, +) import attr -from . import utils -from .parsing import Statement +from . import ( + utils, +) +from .parsing import ( + Statement, +) @attr.s(frozen=True) diff --git a/cmd2/parsing.py b/cmd2/parsing.py index c420e9aa..acf9b471 100755 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -4,12 +4,24 @@ import re import shlex -from typing import Dict, Iterable, List, Optional, Tuple, Union +from typing import ( + Dict, + Iterable, + List, + Optional, + Tuple, + Union, +) import attr -from . import constants, utils -from .exceptions import Cmd2ShlexError +from . import ( + constants, + utils, +) +from .exceptions import ( + Cmd2ShlexError, +) def shlex_split(str_to_split: str) -> List[str]: diff --git a/cmd2/py_bridge.py b/cmd2/py_bridge.py index 38fef142..a9b8641d 100644 --- a/cmd2/py_bridge.py +++ b/cmd2/py_bridge.py @@ -5,10 +5,18 @@ while maintaining a reasonable degree of isolation between the two. """ import sys -from contextlib import redirect_stderr, redirect_stdout -from typing import Optional - -from .utils import StdSim, namedtuple_with_defaults +from contextlib import ( + redirect_stderr, + redirect_stdout, +) +from typing import ( + Optional, +) + +from .utils import ( + StdSim, + namedtuple_with_defaults, +) class CommandResult(namedtuple_with_defaults('CommandResult', ['stdout', 'stderr', 'stop', 'data'])): diff --git a/cmd2/rl_utils.py b/cmd2/rl_utils.py index 099d76b7..e435c3f5 100644 --- a/cmd2/rl_utils.py +++ b/cmd2/rl_utils.py @@ -3,7 +3,9 @@ Imports the proper readline for the platform and provides utility functions for it """ import sys -from enum import Enum +from enum import ( + Enum, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: diff --git a/cmd2/table_creator.py b/cmd2/table_creator.py index 7a5c826c..419f12b4 100644 --- a/cmd2/table_creator.py +++ b/cmd2/table_creator.py @@ -8,13 +8,29 @@ There are already implemented and ready-to-use examples of this below TableCreat import copy import functools import io -from collections import deque -from enum import Enum -from typing import Any, Optional, Sequence, Tuple, Union - -from wcwidth import wcwidth - -from . import ansi, constants, utils +from collections import ( + deque, +) +from enum import ( + Enum, +) +from typing import ( + Any, + Optional, + Sequence, + Tuple, + Union, +) + +from wcwidth import ( + wcwidth, +) + +from . import ( + ansi, + constants, + utils, +) # This is needed for compatibility with early versions of Python 3.5 prior to 3.5.4 try: diff --git a/cmd2/transcript.py b/cmd2/transcript.py index 940c97db..0c65cb8a 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -11,9 +11,14 @@ class is used in cmd2.py::run_transcript_tests() """ import re import unittest -from typing import Tuple - -from . import ansi, utils +from typing import ( + Tuple, +) + +from . import ( + ansi, + utils, +) class Cmd2TestCase(unittest.TestCase): diff --git a/cmd2/utils.py b/cmd2/utils.py index b58cdb96..c88df0ec 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -12,12 +12,26 @@ import re import subprocess import sys import threading - import unicodedata -from enum import Enum -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TextIO, Type, Union - -from . import constants +from enum import ( + Enum, +) +from typing import ( + IO, + Any, + Callable, + Dict, + Iterable, + List, + Optional, + TextIO, + Type, + Union, +) + +from . import ( + constants, +) def is_quoted(arg: str) -> bool: diff --git a/examples/argparse_completion.py b/examples/argparse_completion.py index e44533b3..bd36db29 100644 --- a/examples/argparse_completion.py +++ b/examples/argparse_completion.py @@ -4,10 +4,21 @@ A simple example demonstrating how to integrate tab completion with argparse-based commands. """ import argparse -from typing import Dict, List - -from cmd2 import Cmd, Cmd2ArgumentParser, CompletionItem, with_argparser -from cmd2.utils import CompletionError, basic_complete +from typing import ( + Dict, + List, +) + +from cmd2 import ( + Cmd, + Cmd2ArgumentParser, + CompletionItem, + with_argparser, +) +from cmd2.utils import ( + CompletionError, + basic_complete, +) # Data source for argparse.choices food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato'] diff --git a/examples/async_printing.py b/examples/async_printing.py index a136d8e2..a4e02c92 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -7,10 +7,15 @@ and changes the window title import random import threading import time -from typing import List +from typing import ( + List, +) import cmd2 -from cmd2 import fg, style +from cmd2 import ( + fg, + style, +) ALERTS = ["Watch as this application prints alerts and updates the prompt", "This will only happen when the prompt is present", diff --git a/examples/basic.py b/examples/basic.py index 2a1e9a12..800a0946 100755 --- a/examples/basic.py +++ b/examples/basic.py @@ -9,7 +9,11 @@ 6) Shell-like capabilities """ import cmd2 -from cmd2 import bg, fg, style +from cmd2 import ( + bg, + fg, + style, +) class BasicApp(cmd2.Cmd): diff --git a/examples/basic_completion.py b/examples/basic_completion.py index f33029c9..83e71a50 100755 --- a/examples/basic_completion.py +++ b/examples/basic_completion.py @@ -13,7 +13,9 @@ familiar with argparse. The recommended approach for tab completing positional t argparse-based completion. For an example integrating tab completion with argparse, see argparse_completion.py """ import functools -from typing import List +from typing import ( + List, +) import cmd2 diff --git a/examples/colors.py b/examples/colors.py index 8f8e3c6e..dc5bdb99 100755 --- a/examples/colors.py +++ b/examples/colors.py @@ -24,12 +24,20 @@ Always regardless of the output destination """ import argparse -from typing import Any +from typing import ( + Any, +) -from colorama import Back, Fore, Style +from colorama import ( + Back, + Fore, + Style, +) import cmd2 -from cmd2 import ansi +from cmd2 import ( + ansi, +) class CmdLineApp(cmd2.Cmd): diff --git a/examples/custom_parser.py b/examples/custom_parser.py index 34c7bee2..194b47b8 100644 --- a/examples/custom_parser.py +++ b/examples/custom_parser.py @@ -4,7 +4,11 @@ Defines the CustomParser used with override_parser.py example """ import sys -from cmd2 import Cmd2ArgumentParser, ansi, set_default_argument_parser +from cmd2 import ( + Cmd2ArgumentParser, + ansi, + set_default_argument_parser, +) # First define the parser diff --git a/examples/decorator_example.py b/examples/decorator_example.py index 1b6d7570..29fcbd9e 100755 --- a/examples/decorator_example.py +++ b/examples/decorator_example.py @@ -11,7 +11,9 @@ all the commands in the transcript against decorator_example.py, verifying that the output produced matches the transcript. """ import argparse -from typing import List +from typing import ( + List, +) import cmd2 diff --git a/examples/default_categories.py b/examples/default_categories.py index 19699513..efa6729d 100644 --- a/examples/default_categories.py +++ b/examples/default_categories.py @@ -5,7 +5,10 @@ Simple example demonstrating basic CommandSet usage. """ import cmd2 -from cmd2 import CommandSet, with_default_category +from cmd2 import ( + CommandSet, + with_default_category, +) @with_default_category('Default Category') diff --git a/examples/dynamic_commands.py b/examples/dynamic_commands.py index 620acb7f..35c2cd42 100755 --- a/examples/dynamic_commands.py +++ b/examples/dynamic_commands.py @@ -5,7 +5,10 @@ import functools import cmd2 -from cmd2.constants import COMMAND_FUNC_PREFIX, HELP_FUNC_PREFIX +from cmd2.constants import ( + COMMAND_FUNC_PREFIX, + HELP_FUNC_PREFIX, +) COMMAND_LIST = ['foo', 'bar'] CATEGORY = 'Dynamic Commands' diff --git a/examples/exit_code.py b/examples/exit_code.py index 89ed86cd..062ee12d 100755 --- a/examples/exit_code.py +++ b/examples/exit_code.py @@ -2,7 +2,9 @@ # coding=utf-8 """A simple example demonstrating the following how to emit a non-zero exit code in your cmd2 application. """ -from typing import List +from typing import ( + List, +) import cmd2 diff --git a/examples/hello_cmd2.py b/examples/hello_cmd2.py index 94ec334f..06303722 100755 --- a/examples/hello_cmd2.py +++ b/examples/hello_cmd2.py @@ -3,7 +3,9 @@ """ This is intended to be a completely bare-bones cmd2 application suitable for rapid testing and debugging. """ -from cmd2 import cmd2 +from cmd2 import ( + cmd2, +) if __name__ == '__main__': import sys diff --git a/examples/help_categories.py b/examples/help_categories.py index 7401bafe..0b25375a 100755 --- a/examples/help_categories.py +++ b/examples/help_categories.py @@ -8,7 +8,9 @@ It also demonstrates the effects of decorator order when it comes to argparse er import functools import cmd2 -from cmd2 import COMMAND_NAME +from cmd2 import ( + COMMAND_NAME, +) def my_decorator(f): diff --git a/examples/hooks.py b/examples/hooks.py index f8079e58..8acbf91b 100755 --- a/examples/hooks.py +++ b/examples/hooks.py @@ -10,7 +10,9 @@ follow a command without any intervening whitespace. """ import re -from typing import List +from typing import ( + List, +) import cmd2 diff --git a/examples/initialization.py b/examples/initialization.py index 50bb73aa..76a136dd 100755 --- a/examples/initialization.py +++ b/examples/initialization.py @@ -13,7 +13,11 @@ 10) How to make custom attributes settable at runtime """ import cmd2 -from cmd2 import bg, fg, style +from cmd2 import ( + bg, + fg, + style, +) class BasicApp(cmd2.Cmd): diff --git a/examples/modular_commands/commandset_basic.py b/examples/modular_commands/commandset_basic.py index 2ceda439..4417bfe5 100644 --- a/examples/modular_commands/commandset_basic.py +++ b/examples/modular_commands/commandset_basic.py @@ -2,10 +2,20 @@ """ A simple example demonstrating a loadable command set """ -from typing import List - -from cmd2 import Cmd, CommandSet, Statement, with_category, with_default_category -from cmd2.utils import CompletionError +from typing import ( + List, +) + +from cmd2 import ( + Cmd, + CommandSet, + Statement, + with_category, + with_default_category, +) +from cmd2.utils import ( + CompletionError, +) @with_default_category('Basic Completion') diff --git a/examples/modular_commands/commandset_complex.py b/examples/modular_commands/commandset_complex.py index 579c0677..4905265a 100644 --- a/examples/modular_commands/commandset_complex.py +++ b/examples/modular_commands/commandset_complex.py @@ -5,10 +5,14 @@ Test CommandSet """ import argparse -from typing import List +from typing import ( + List, +) import cmd2 -from cmd2 import utils +from cmd2 import ( + utils, +) @cmd2.with_default_category('Fruits') diff --git a/examples/modular_commands/commandset_custominit.py b/examples/modular_commands/commandset_custominit.py index 2ef94a75..e24ac291 100644 --- a/examples/modular_commands/commandset_custominit.py +++ b/examples/modular_commands/commandset_custominit.py @@ -2,7 +2,12 @@ """ A simple example demonstrating a loadable command set """ -from cmd2 import Cmd, CommandSet, Statement, with_default_category +from cmd2 import ( + Cmd, + CommandSet, + Statement, + with_default_category, +) @with_default_category('Custom Init') diff --git a/examples/modular_commands_basic.py b/examples/modular_commands_basic.py index b9d4c4a2..4d5f83ce 100644 --- a/examples/modular_commands_basic.py +++ b/examples/modular_commands_basic.py @@ -5,7 +5,10 @@ Simple example demonstrating basic CommandSet usage. """ import cmd2 -from cmd2 import CommandSet, with_default_category +from cmd2 import ( + CommandSet, + with_default_category, +) @with_default_category('My Category') diff --git a/examples/modular_commands_dynamic.py b/examples/modular_commands_dynamic.py index b2be5dd1..8264c068 100644 --- a/examples/modular_commands_dynamic.py +++ b/examples/modular_commands_dynamic.py @@ -10,8 +10,14 @@ on which CommandSets are loaded """ import argparse + import cmd2 -from cmd2 import CommandSet, with_argparser, with_category, with_default_category +from cmd2 import ( + CommandSet, + with_argparser, + with_category, + with_default_category, +) @with_default_category('Fruits') diff --git a/examples/modular_commands_main.py b/examples/modular_commands_main.py index b698e00f..2c652f22 100644 --- a/examples/modular_commands_main.py +++ b/examples/modular_commands_main.py @@ -5,13 +5,33 @@ A complex example demonstrating a variety of methods to load CommandSets using a with examples of how to integrate tab completion with argparse-based commands. """ import argparse -from typing import Dict, Iterable, List, Optional - -from cmd2 import Cmd, Cmd2ArgumentParser, CommandSet, CompletionItem, with_argparser -from cmd2.utils import CompletionError, basic_complete -from modular_commands.commandset_basic import BasicCompletionCommandSet # noqa: F401 -from modular_commands.commandset_complex import CommandSetA # noqa: F401 -from modular_commands.commandset_custominit import CustomInitCommandSet # noqa: F401 +from typing import ( + Dict, + Iterable, + List, + Optional, +) + +from cmd2 import ( + Cmd, + Cmd2ArgumentParser, + CommandSet, + CompletionItem, + with_argparser, +) +from cmd2.utils import ( + CompletionError, + basic_complete, +) +from modular_commands.commandset_basic import ( # noqa: F401 + BasicCompletionCommandSet, +) +from modular_commands.commandset_complex import ( # noqa: F401 + CommandSetA, +) +from modular_commands.commandset_custominit import ( + CustomInitCommandSet, # noqa: F401 +) # Data source for argparse.choices food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato'] diff --git a/examples/modular_subcommands.py b/examples/modular_subcommands.py index c1d499f0..082903fb 100644 --- a/examples/modular_subcommands.py +++ b/examples/modular_subcommands.py @@ -11,8 +11,14 @@ The `load` and `unload` command will load and unload the CommandSets. The availa subcommands to the `cut` command will change depending on which CommandSets are loaded. """ import argparse + import cmd2 -from cmd2 import CommandSet, with_argparser, with_category, with_default_category +from cmd2 import ( + CommandSet, + with_argparser, + with_category, + with_default_category, +) @with_default_category('Fruits') diff --git a/examples/override_parser.py b/examples/override_parser.py index b6548388..b723f6d7 100755 --- a/examples/override_parser.py +++ b/examples/override_parser.py @@ -13,7 +13,9 @@ import argparse # Next import stuff from cmd2. It will import your module just before the cmd2.Cmd class file is imported # and therefore override the parser class it uses on its commands. -from cmd2 import cmd2 +from cmd2 import ( + cmd2, +) argparse.cmd2_parser_module = 'examples.custom_parser' diff --git a/examples/paged_output.py b/examples/paged_output.py index cba5c7c5..191fdd7f 100755 --- a/examples/paged_output.py +++ b/examples/paged_output.py @@ -3,7 +3,9 @@ """A simple example demonstrating the using paged output via the ppaged() method. """ import os -from typing import List +from typing import ( + List, +) import cmd2 diff --git a/examples/pirate.py b/examples/pirate.py index a50f9a51..ab2403be 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -10,7 +10,9 @@ import argparse import cmd2 import cmd2.ansi -from cmd2.constants import MULTILINE_TERMINATOR +from cmd2.constants import ( + MULTILINE_TERMINATOR, +) class Pirate(cmd2.Cmd): diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py index a30e4c70..ec138e89 100755 --- a/examples/plumbum_colors.py +++ b/examples/plumbum_colors.py @@ -28,8 +28,13 @@ WARNING: This example requires the plumbum package, which isn't normally require import argparse import cmd2 -from cmd2 import ansi -from plumbum.colors import bg, fg +from cmd2 import ( + ansi, +) +from plumbum.colors import ( + bg, + fg, +) class FgColors(ansi.ColorBase): diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 6e4295d4..5d3f43b3 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -24,7 +24,9 @@ import argparse import os import cmd2 -from cmd2 import ansi +from cmd2 import ( + ansi, +) class CmdLineApp(cmd2.Cmd): diff --git a/examples/scripts/save_help_text.py b/examples/scripts/save_help_text.py index cc4cfcc7..ad028395 100644 --- a/examples/scripts/save_help_text.py +++ b/examples/scripts/save_help_text.py @@ -8,7 +8,10 @@ This is meant to be run within a cmd2 session using run_pyscript. import argparse import os import sys -from typing import List, TextIO +from typing import ( + List, + TextIO, +) ASTERISKS = "********************************************************" diff --git a/examples/table_creation.py b/examples/table_creation.py index 6325b200..a290f5df 100755 --- a/examples/table_creation.py +++ b/examples/table_creation.py @@ -3,10 +3,21 @@ """Examples of using the cmd2 table creation API""" import functools import sys -from typing import Any, List - -from cmd2 import ansi -from cmd2.table_creator import AlternatingTable, BorderedTable, Column, HorizontalAlignment, SimpleTable +from typing import ( + Any, + List, +) + +from cmd2 import ( + ansi, +) +from cmd2.table_creator import ( + AlternatingTable, + BorderedTable, + Column, + HorizontalAlignment, + SimpleTable, +) class DollarFormatter: diff --git a/plugins/ext_test/cmd2_ext_test/__init__.py b/plugins/ext_test/cmd2_ext_test/__init__.py index 21fd000b..ded8612c 100644 --- a/plugins/ext_test/cmd2_ext_test/__init__.py +++ b/plugins/ext_test/cmd2_ext_test/__init__.py @@ -17,7 +17,9 @@ except importlib_metadata.PackageNotFoundError: # pragma: no cover # package is not installed __version__ = 'unknown' -from .cmd2_ext_test import ExternalTestMixin +from .cmd2_ext_test import ( + ExternalTestMixin, +) __all__ = [ 'ExternalTestMixin' diff --git a/plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py b/plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py index b1827f02..c176bb78 100644 --- a/plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py +++ b/plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py @@ -2,7 +2,10 @@ # coding=utf-8 """External test interface plugin""" -from typing import TYPE_CHECKING, Optional +from typing import ( + TYPE_CHECKING, + Optional, +) import cmd2 diff --git a/plugins/ext_test/tests/test_ext_test.py b/plugins/ext_test/tests/test_ext_test.py index b1ba1b7d..d55911c3 100644 --- a/plugins/ext_test/tests/test_ext_test.py +++ b/plugins/ext_test/tests/test_ext_test.py @@ -4,7 +4,10 @@ import pytest import cmd2_ext_test -from cmd2 import CommandResult, cmd2 +from cmd2 import ( + CommandResult, + cmd2, +) ###### # diff --git a/plugins/tasks.py b/plugins/tasks.py index 1a70e4f2..f198c34e 100644 --- a/plugins/tasks.py +++ b/plugins/tasks.py @@ -10,8 +10,12 @@ Make sure you satisfy the following Python module requirements if you are trying """ import invoke -from plugins.ext_test import tasks as ext_test_tasks -from plugins.template import tasks as template_tasks +from plugins.ext_test import ( + tasks as ext_test_tasks, +) +from plugins.template import ( + tasks as template_tasks, +) # create namespaces namespace = invoke.Collection(ext_test=ext_test_tasks, diff --git a/plugins/template/cmd2_myplugin/__init__.py b/plugins/template/cmd2_myplugin/__init__.py index 838d828a..daa20e71 100644 --- a/plugins/template/cmd2_myplugin/__init__.py +++ b/plugins/template/cmd2_myplugin/__init__.py @@ -5,7 +5,10 @@ An overview of what myplugin does. """ -from .myplugin import MyPluginMixin, empty_decorator # noqa: F401 +from .myplugin import ( # noqa: F401 + MyPluginMixin, + empty_decorator, +) try: # For python 3.8 and later diff --git a/plugins/template/cmd2_myplugin/myplugin.py b/plugins/template/cmd2_myplugin/myplugin.py index 816198b0..c0467366 100644 --- a/plugins/template/cmd2_myplugin/myplugin.py +++ b/plugins/template/cmd2_myplugin/myplugin.py @@ -3,7 +3,10 @@ """An example cmd2 plugin""" import functools -from typing import TYPE_CHECKING, Callable +from typing import ( + TYPE_CHECKING, + Callable, +) import cmd2 diff --git a/plugins/template/tests/test_myplugin.py b/plugins/template/tests/test_myplugin.py index d61181a6..a61490ca 100644 --- a/plugins/template/tests/test_myplugin.py +++ b/plugins/template/tests/test_myplugin.py @@ -2,7 +2,9 @@ # coding=utf-8 import cmd2_myplugin -from cmd2 import cmd2 +from cmd2 import ( + cmd2, +) ###### # @@ -8,7 +8,7 @@ max-line-length = 127 max-complexity = 26 [isort] -line_length=127 +line_length=1 skip=cmd2/__init__.py multi_line_output = 3 include_trailing_comma = true @@ -5,7 +5,9 @@ Setuptools setup file, used to install or test 'cmd2' """ import codecs -from setuptools import setup +from setuptools import ( + setup, +) DESCRIPTION = "cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python" @@ -16,7 +16,9 @@ import sys import invoke -from plugins import tasks as plugin_tasks +from plugins import ( + tasks as plugin_tasks, +) TASK_ROOT = pathlib.Path(__file__).resolve().parent TASK_ROOT_STR = str(TASK_ROOT) @@ -96,7 +98,7 @@ namespace_clean.add_task(pytest_clean, 'pytest') def mypy(context): """Run mypy optional static type checker""" with context.cd(TASK_ROOT_STR): - context.run("mypy main.py") + context.run("mypy cmd2") namespace.add_task(mypy) diff --git a/tests/conftest.py b/tests/conftest.py index 73080b5c..c0b9e385 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,14 +3,27 @@ Cmd2 unit/functional testing """ import sys -from contextlib import redirect_stderr, redirect_stdout -from typing import List, Optional, Union -from unittest import mock - -from pytest import fixture +from contextlib import ( + redirect_stderr, + redirect_stdout, +) +from typing import ( + List, + Optional, + Union, +) +from unittest import ( + mock, +) + +from pytest import ( + fixture, +) import cmd2 -from cmd2.utils import StdSim +from cmd2.utils import ( + StdSim, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: diff --git a/tests/test_argparse.py b/tests/test_argparse.py index 7059e9d3..e7806056 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -4,13 +4,17 @@ Cmd2 testing for argument parsing """ import argparse -from typing import Optional +from typing import ( + Optional, +) import pytest import cmd2 -from .conftest import run_cmd +from .conftest import ( + run_cmd, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: @@ -457,4 +461,3 @@ def test_pytest_mock_invalid(mocker): def test_pytest_mock_valid(mocker, spec_param): mocker.patch.object(ArgparseApp, 'namespace_provider', **spec_param) app = ArgparseApp() - diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py index dd86163b..6c3c63fb 100644 --- a/tests/test_argparse_completer.py +++ b/tests/test_argparse_completer.py @@ -5,14 +5,28 @@ Unit/functional testing for argparse completer in cmd2 """ import argparse import numbers -from typing import List +from typing import ( + List, +) import pytest import cmd2 -from cmd2 import Cmd2ArgumentParser, CompletionItem, with_argparser -from cmd2.utils import CompletionError, StdSim, basic_complete -from .conftest import complete_tester, run_cmd +from cmd2 import ( + Cmd2ArgumentParser, + CompletionItem, + with_argparser, +) +from cmd2.utils import ( + CompletionError, + StdSim, + basic_complete, +) + +from .conftest import ( + complete_tester, + run_cmd, +) # Lists used in our tests (there is a mix of sorted and unsorted on purpose) non_negative_int_choices = [1, 2, 3, 0, 22] diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index e2b3bb97..4bd41264 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -7,10 +7,17 @@ import argparse import pytest import cmd2 -from cmd2 import Cmd2ArgumentParser, constants -from cmd2.argparse_custom import generate_range_error - -from .conftest import run_cmd +from cmd2 import ( + Cmd2ArgumentParser, + constants, +) +from cmd2.argparse_custom import ( + generate_range_error, +) + +from .conftest import ( + run_cmd, +) class ApCustomTestApp(cmd2.Cmd): diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 5874bcb2..a2299abe 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -9,12 +9,22 @@ import io import os import sys import tempfile -from code import InteractiveConsole +from code import ( + InteractiveConsole, +) import pytest import cmd2 -from cmd2 import COMMAND_NAME, ansi, clipboard, constants, exceptions, plugin, utils +from cmd2 import ( + COMMAND_NAME, + ansi, + clipboard, + constants, + exceptions, + plugin, + utils, +) from .conftest import ( HELP_HISTORY, diff --git a/tests/test_completion.py b/tests/test_completion.py index db243f48..0d8f6eb1 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -20,10 +20,18 @@ import sys import pytest import cmd2 -from cmd2 import utils -from examples.subcommands import SubcommandsExample - -from .conftest import complete_tester, normalize, run_cmd +from cmd2 import ( + utils, +) +from examples.subcommands import ( + SubcommandsExample, +) + +from .conftest import ( + complete_tester, + normalize, + run_cmd, +) # List of strings used with completion functions food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato', 'Cheese "Pizza"'] diff --git a/tests/test_history.py b/tests/test_history.py index 6fa16ad8..ac8c6cb6 100755 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -11,9 +11,15 @@ import pytest import cmd2 # Python 3.5 had some regressions in the unitest.mock module, so use # 3rd party mock if available -from cmd2.parsing import StatementParser - -from .conftest import HELP_HISTORY, normalize, run_cmd +from cmd2.parsing import ( + StatementParser, +) + +from .conftest import ( + HELP_HISTORY, + normalize, + run_cmd, +) try: import mock diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 2eccec7c..abf8b9fd 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -7,8 +7,15 @@ import attr import pytest import cmd2 -from cmd2 import constants, exceptions, utils -from cmd2.parsing import StatementParser, shlex_split +from cmd2 import ( + constants, + exceptions, + utils, +) +from cmd2.parsing import ( + StatementParser, + shlex_split, +) @pytest.fixture diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 279f2f79..4a019b15 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -9,7 +9,12 @@ import sys import pytest import cmd2 -from cmd2 import Cmd2ArgumentParser, exceptions, plugin, with_argparser +from cmd2 import ( + Cmd2ArgumentParser, + exceptions, + plugin, + with_argparser, +) # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available try: diff --git a/tests/test_run_pyscript.py b/tests/test_run_pyscript.py index 8cfd8578..a46a3ca3 100644 --- a/tests/test_run_pyscript.py +++ b/tests/test_run_pyscript.py @@ -8,9 +8,15 @@ import os import pytest -from cmd2 import plugin, utils - -from .conftest import odd_file_names, run_cmd +from cmd2 import ( + plugin, + utils, +) + +from .conftest import ( + odd_file_names, + run_cmd, +) # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available try: diff --git a/tests/test_table_creator.py b/tests/test_table_creator.py index 0d2edfb2..58dd6fdf 100644 --- a/tests/test_table_creator.py +++ b/tests/test_table_creator.py @@ -5,7 +5,9 @@ Unit testing for cmd2/table_creator.py module """ import pytest -from cmd2 import ansi +from cmd2 import ( + ansi, +) from cmd2.table_creator import ( AlternatingTable, BorderedTable, diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 55d60e18..1b9c71fe 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -9,15 +9,25 @@ import random import re import sys import tempfile -from unittest import mock +from unittest import ( + mock, +) import pytest import cmd2 -from cmd2 import transcript -from cmd2.utils import Settable, StdSim - -from .conftest import run_cmd, verify_help_text +from cmd2 import ( + transcript, +) +from cmd2.utils import ( + Settable, + StdSim, +) + +from .conftest import ( + run_cmd, + verify_help_text, +) class CmdLineApp(cmd2.Cmd): diff --git a/tests/test_utils.py b/tests/test_utils.py index 5336ccfd..e6853570 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -10,13 +10,16 @@ import time import pytest +import cmd2.utils as cu +from cmd2.constants import ( + HORIZONTAL_ELLIPSIS, +) + try: import mock except ImportError: from unittest import mock -import cmd2.utils as cu -from cmd2.constants import HORIZONTAL_ELLIPSIS HELLO_WORLD = 'Hello, world!' diff --git a/tests_isolated/test_commandset/conftest.py b/tests_isolated/test_commandset/conftest.py index 037be199..e6050f8d 100644 --- a/tests_isolated/test_commandset/conftest.py +++ b/tests_isolated/test_commandset/conftest.py @@ -3,15 +3,30 @@ Cmd2 unit/functional testing """ import sys -from contextlib import redirect_stderr, redirect_stdout -from typing import List, Optional, Union -from unittest import mock - -from pytest import fixture +from contextlib import ( + redirect_stderr, + redirect_stdout, +) +from typing import ( + List, + Optional, + Union, +) +from unittest import ( + mock, +) + +from pytest import ( + fixture, +) import cmd2 -from cmd2_ext_test import ExternalTestMixin -from cmd2.utils import StdSim +from cmd2.utils import ( + StdSim, +) +from cmd2_ext_test import ( + ExternalTestMixin, +) # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: diff --git a/tests_isolated/test_commandset/test_argparse_subcommands.py b/tests_isolated/test_commandset/test_argparse_subcommands.py index bd2bed42..9618a53a 100644 --- a/tests_isolated/test_commandset/test_argparse_subcommands.py +++ b/tests_isolated/test_commandset/test_argparse_subcommands.py @@ -9,7 +9,11 @@ import argparse import pytest import cmd2 -from .conftest import run_cmd, WithCommandSets + +from .conftest import ( + WithCommandSets, + run_cmd, +) class SubcommandSet(cmd2.CommandSet): diff --git a/tests_isolated/test_commandset/test_categories.py b/tests_isolated/test_commandset/test_categories.py index c266e0d4..905d68a8 100644 --- a/tests_isolated/test_commandset/test_categories.py +++ b/tests_isolated/test_commandset/test_categories.py @@ -3,10 +3,15 @@ """ Simple example demonstrating basic CommandSet usage. """ -from typing import Any +from typing import ( + Any, +) import cmd2 -from cmd2 import CommandSet, with_default_category +from cmd2 import ( + CommandSet, + with_default_category, +) @with_default_category('Default Category') diff --git a/tests_isolated/test_commandset/test_commandset.py b/tests_isolated/test_commandset/test_commandset.py index 21cce8bf..7a192888 100644 --- a/tests_isolated/test_commandset/test_commandset.py +++ b/tests_isolated/test_commandset/test_commandset.py @@ -5,14 +5,24 @@ Test CommandSet """ import argparse -from typing import List +from typing import ( + List, +) import pytest import cmd2 -from cmd2 import utils -from .conftest import complete_tester, WithCommandSets -from cmd2.exceptions import CommandSetRegistrationError +from cmd2 import ( + utils, +) +from cmd2.exceptions import ( + CommandSetRegistrationError, +) + +from .conftest import ( + WithCommandSets, + complete_tester, +) class CommandSetBase(cmd2.CommandSet): |