summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2021-01-05 11:29:39 -0500
committeranselor <anselor@gmail.com>2021-01-22 10:40:50 -0500
commita3b1b6ddf81cdc0b253f15feeb167ff348afd14f (patch)
tree2556f4aa57d02e12526949c08cf032c3e1a67d11 /cmd2
parentc1859045c8d439932fac9ceb5203a400db609533 (diff)
downloadcmd2-git-a3b1b6ddf81cdc0b253f15feeb167ff348afd14f.tar.gz
Changed isort to force wrapping of imports to reduce merge conflicts from minor import changes.
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/ansi.py21
-rw-r--r--cmd2/argparse_completer.py31
-rw-r--r--cmd2/argparse_custom.py23
-rw-r--r--cmd2/clipboard.py4
-rw-r--r--cmd2/cmd2.py94
-rw-r--r--cmd2/command_definition.py16
-rw-r--r--cmd2/decorators.py30
-rw-r--r--cmd2/history.py13
-rwxr-xr-xcmd2/parsing.py18
-rw-r--r--cmd2/py_bridge.py16
-rw-r--r--cmd2/rl_utils.py4
-rw-r--r--cmd2/table_creator.py30
-rw-r--r--cmd2/transcript.py11
-rw-r--r--cmd2/utils.py24
14 files changed, 267 insertions, 68 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: