Skip to content

Commit

Permalink
Changed isort to force wrapping of imports to reduce merge conflicts …
Browse files Browse the repository at this point in the history
…from minor import changes.
  • Loading branch information
anselor committed Jan 22, 2021
1 parent c185904 commit a3b1b6d
Show file tree
Hide file tree
Showing 69 changed files with 668 additions and 182 deletions.
21 changes: 17 additions & 4 deletions cmd2/ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@
"""
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)
Expand Down
31 changes: 25 additions & 6 deletions cmd2/argparse_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@
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,
Expand All @@ -23,9 +34,17 @@
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'
Expand Down
23 changes: 19 additions & 4 deletions cmd2/argparse_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,25 @@ def my_completer_method(self, text, line, begidx, endidx, arg_tokens)
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
Expand Down
4 changes: 3 additions & 1 deletion cmd2/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""
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:
Expand Down
94 changes: 77 additions & 17 deletions cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,89 @@
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
Expand Down
16 changes: 12 additions & 4 deletions cmd2/command_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 24 additions & 6 deletions cmd2/decorators.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 10 additions & 3 deletions cmd2/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
"""

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)
Expand Down
18 changes: 15 additions & 3 deletions cmd2/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
16 changes: 12 additions & 4 deletions cmd2/py_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
"""

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'])):
Expand Down
4 changes: 3 additions & 1 deletion cmd2/rl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit a3b1b6d

Please sign in to comment.