Skip to content

Commit 9cb49fb

Browse files
committed
Add in isort changes
1 parent 43be550 commit 9cb49fb

57 files changed

Lines changed: 441 additions & 145 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/format.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ jobs:
2525
- name: Install python prerequisites
2626
run: pip install -U --user pip setuptools setuptools-scm black
2727
- name: Black
28-
run: python -m black --check --diff -l 127 --skip-string-normalization .
28+
run: python -m black --check --diff .
29+
- name: isort
30+
run: python -m isort --check-only .

cmd2/ansi.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"""
66
import functools
77
import re
8-
from enum import Enum
8+
from enum import (
9+
Enum,
10+
)
911
from typing import (
1012
IO,
1113
Any,
@@ -19,7 +21,9 @@
1921
Fore,
2022
Style,
2123
)
22-
from wcwidth import wcswidth
24+
from wcwidth import (
25+
wcswidth,
26+
)
2327

2428
# On Windows, filter ANSI escape codes out of text sent to stdout/stderr, and replace them with equivalent Win32 calls
2529
colorama.init(strip=False)
@@ -319,7 +323,9 @@ def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_off
319323
:param alert_msg: the message to display to the user
320324
:return: the correct string so that the alert message appears to the user to be printed above the current line.
321325
"""
322-
from colorama import Cursor
326+
from colorama import (
327+
Cursor,
328+
)
323329

324330
# Split the prompt lines since it can contain newline characters.
325331
prompt_lines = prompt.splitlines()

cmd2/argparse_completer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import inspect
1111
import numbers
1212
import shutil
13-
from collections import deque
13+
from collections import (
14+
deque,
15+
)
1416
from typing import (
1517
Dict,
1618
List,
@@ -32,7 +34,9 @@
3234
CompletionItem,
3335
generate_range_error,
3436
)
35-
from .command_definition import CommandSet
37+
from .command_definition import (
38+
CommandSet,
39+
)
3640
from .table_creator import (
3741
Column,
3842
SimpleTable,

cmd2/clipboard.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import pyperclip
66

77
# noinspection PyProtectedMember
8-
from pyperclip import PyperclipException
8+
from pyperclip import (
9+
PyperclipException,
10+
)
911

1012
# Can we access the clipboard? Should always be true on Windows and Mac, but only sometimes on Linux
1113
try:

cmd2/cmd2.py

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@
3838
import re
3939
import sys
4040
import threading
41-
from code import InteractiveConsole
42-
from collections import namedtuple
43-
from contextlib import redirect_stdout
41+
from code import (
42+
InteractiveConsole,
43+
)
44+
from collections import (
45+
namedtuple,
46+
)
47+
from contextlib import (
48+
redirect_stdout,
49+
)
4450
from typing import (
4551
Any,
4652
Callable,
@@ -69,7 +75,9 @@
6975
get_paste_buffer,
7076
write_to_paste_buffer,
7177
)
72-
from .command_definition import CommandSet
78+
from .command_definition import (
79+
CommandSet,
80+
)
7381
from .constants import (
7482
CLASS_ATTR_DEFAULT_HELP_CATEGORY,
7583
COMMAND_FUNC_PREFIX,
@@ -118,7 +126,10 @@
118126
if rl_type == RlType.NONE: # pragma: no cover
119127
sys.stderr.write(ansi.style_warning(rl_warning))
120128
else:
121-
from .rl_utils import rl_force_redisplay, readline
129+
from .rl_utils import (
130+
readline,
131+
rl_force_redisplay,
132+
)
122133

123134
# Used by rlcompleter in Python console loaded by py command
124135
orig_rl_delims = readline.get_completer_delims()
@@ -133,7 +144,10 @@
133144

134145
# Get the readline lib so we can make changes to it
135146
import ctypes
136-
from .rl_utils import readline_lib
147+
148+
from .rl_utils import (
149+
readline_lib,
150+
)
137151

138152
rl_basic_quote_characters = ctypes.c_char_p.in_dll(readline_lib, "rl_basic_quote_characters")
139153
orig_rl_basic_quotes = ctypes.cast(rl_basic_quote_characters, ctypes.c_void_p).value
@@ -142,7 +156,9 @@
142156
ipython_available = True
143157
try:
144158
# noinspection PyUnresolvedReferences,PyPackageRequirements
145-
from IPython import embed
159+
from IPython import (
160+
embed,
161+
)
146162
except ImportError: # pragma: no cover
147163
ipython_available = False
148164

@@ -1976,7 +1992,9 @@ def _complete_argparse_command(
19761992
cmd_set: Optional[CommandSet] = None
19771993
) -> List[str]:
19781994
"""Completion function for argparse commands"""
1979-
from .argparse_completer import ArgparseCompleter
1995+
from .argparse_completer import (
1996+
ArgparseCompleter,
1997+
)
19801998

19811999
completer = ArgparseCompleter(argparser, self)
19822000
tokens, raw_tokens = self.tokens_for_completion(line, begidx, endidx)
@@ -3283,7 +3301,9 @@ def complete_help_subcommands(
32833301
# Combine the command and its subcommand tokens for the ArgparseCompleter
32843302
tokens = [command] + arg_tokens['subcommands']
32853303

3286-
from .argparse_completer import ArgparseCompleter
3304+
from .argparse_completer import (
3305+
ArgparseCompleter,
3306+
)
32873307

32883308
completer = ArgparseCompleter(argparser, self)
32893309
return completer.complete_subcommand_help(tokens, text, line, begidx, endidx)
@@ -3322,7 +3342,9 @@ def do_help(self, args: argparse.Namespace) -> None:
33223342

33233343
# If the command function uses argparse, then use argparse's help
33243344
if func is not None and argparser is not None:
3325-
from .argparse_completer import ArgparseCompleter
3345+
from .argparse_completer import (
3346+
ArgparseCompleter,
3347+
)
33263348

33273349
completer = ArgparseCompleter(argparser, self)
33283350
tokens = [args.command] + args.subcommands
@@ -3573,7 +3595,9 @@ def complete_set_value(
35733595
completer_method=settable.completer_method,
35743596
)
35753597

3576-
from .argparse_completer import ArgparseCompleter
3598+
from .argparse_completer import (
3599+
ArgparseCompleter,
3600+
)
35773601

35783602
completer = ArgparseCompleter(settable_parser, self)
35793603

@@ -3861,7 +3885,9 @@ def py_quit():
38613885
"""Function callable from the interactive Python console to exit that environment"""
38623886
raise EmbeddedConsoleExit
38633887

3864-
from .py_bridge import PyBridge
3888+
from .py_bridge import (
3889+
PyBridge,
3890+
)
38653891

38663892
py_bridge = PyBridge(self)
38673893
saved_sys_path = None
@@ -4016,7 +4042,9 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]:
40164042
40174043
:return: True if running of commands should stop
40184044
"""
4019-
from .py_bridge import PyBridge
4045+
from .py_bridge import (
4046+
PyBridge,
4047+
)
40204048

40214049
# noinspection PyUnusedLocal
40224050
def load_ipy(cmd2_app: Cmd, py_bridge: PyBridge):
@@ -4559,8 +4587,12 @@ def _run_transcript_tests(self, transcript_paths: List[str]) -> None:
45594587
"""
45604588
import time
45614589
import unittest
4590+
45624591
import cmd2
4563-
from .transcript import Cmd2TestCase
4592+
4593+
from .transcript import (
4594+
Cmd2TestCase,
4595+
)
45644596

45654597
class TestMyAppCase(Cmd2TestCase):
45664598
cmdapp = self

cmd2/command_definition.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
CLASS_ATTR_DEFAULT_HELP_CATEGORY,
1212
COMMAND_FUNC_PREFIX,
1313
)
14-
from .exceptions import CommandSetRegistrationError
14+
from .exceptions import (
15+
CommandSetRegistrationError,
16+
)
1517

1618
# Allows IDEs to resolve types without impacting imports at runtime, breaking circular dependency issues
1719
try: # pragma: no cover
18-
from typing import TYPE_CHECKING
20+
from typing import (
21+
TYPE_CHECKING,
22+
)
1923

2024
if TYPE_CHECKING:
2125
import cmd2
@@ -47,9 +51,14 @@ def decorate_class(cls: Type[CommandSet]):
4751
if heritable:
4852
setattr(cls, CLASS_ATTR_DEFAULT_HELP_CATEGORY, category)
4953

50-
from .constants import CMD_ATTR_HELP_CATEGORY
5154
import inspect
52-
from .decorators import with_category
55+
56+
from .constants import (
57+
CMD_ATTR_HELP_CATEGORY,
58+
)
59+
from .decorators import (
60+
with_category,
61+
)
5362

5463
# get members of the class that meet the following criteria:
5564
# 1. Must be a function

cmd2/decorators.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
Union,
1414
)
1515

16-
from . import constants
17-
from .argparse_custom import Cmd2AttributeWrapper
18-
from .exceptions import Cmd2ArgparseError
19-
from .parsing import Statement
16+
from . import (
17+
constants,
18+
)
19+
from .argparse_custom import (
20+
Cmd2AttributeWrapper,
21+
)
22+
from .exceptions import (
23+
Cmd2ArgparseError,
24+
)
25+
from .parsing import (
26+
Statement,
27+
)
2028

2129
if TYPE_CHECKING: # pragma: no cover
2230
import cmd2
@@ -40,7 +48,9 @@ def with_category(category: str) -> Callable:
4048
"""
4149

4250
def cat_decorator(func):
43-
from .utils import categorize
51+
from .utils import (
52+
categorize,
53+
)
4454

4555
categorize(func, category)
4656
return func
@@ -63,7 +73,10 @@ def _parse_positionals(args: Tuple) -> Tuple[Union['cmd2.Cmd', 'cmd2.CommandSet'
6373
:return: The cmd2.Cmd reference and the command line statement
6474
"""
6575
for pos, arg in enumerate(args):
66-
from cmd2 import Cmd, CommandSet
76+
from cmd2 import (
77+
Cmd,
78+
CommandSet,
79+
)
6780

6881
if (isinstance(arg, Cmd) or isinstance(arg, CommandSet)) and len(args) > pos:
6982
if isinstance(arg, CommandSet):

cmd2/history.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212
import attr
1313

14-
from . import utils
15-
from .parsing import Statement
14+
from . import (
15+
utils,
16+
)
17+
from .parsing import (
18+
Statement,
19+
)
1620

1721

1822
@attr.s(frozen=True)

cmd2/parsing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
constants,
2020
utils,
2121
)
22-
from .exceptions import Cmd2ShlexError
22+
from .exceptions import (
23+
Cmd2ShlexError,
24+
)
2325

2426

2527
def shlex_split(str_to_split: str) -> List[str]:

cmd2/py_bridge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
redirect_stderr,
1010
redirect_stdout,
1111
)
12-
from typing import Optional
12+
from typing import (
13+
Optional,
14+
)
1315

1416
from .utils import (
1517
StdSim,

0 commit comments

Comments
 (0)