|
1 | 1 | """Import certain things for backwards compatibility."""
|
2 | 2 |
|
3 |
| -import argparse |
4 | 3 | import contextlib
|
5 | 4 | import importlib.metadata as importlib_metadata
|
6 |
| -import sys |
7 | 5 |
|
8 | 6 | with contextlib.suppress(importlib_metadata.PackageNotFoundError):
|
9 | 7 | __version__ = importlib_metadata.version(__name__)
|
10 | 8 |
|
| 9 | +from . import plugin |
11 | 10 | from .ansi import (
|
12 | 11 | Bg,
|
13 | 12 | Cursor,
|
|
19 | 18 | TextStyle,
|
20 | 19 | style,
|
21 | 20 | )
|
| 21 | +from .argparse_completer import set_default_ap_completer_type |
22 | 22 | from .argparse_custom import (
|
23 | 23 | Cmd2ArgumentParser,
|
24 | 24 | Cmd2AttributeWrapper,
|
25 | 25 | CompletionItem,
|
26 | 26 | register_argparse_argument_parameter,
|
27 | 27 | set_default_argument_parser_type,
|
28 | 28 | )
|
29 |
| - |
30 |
| -# Check if user has defined a module that sets a custom value for argparse_custom.DEFAULT_ARGUMENT_PARSER. |
31 |
| -# Do this before loading cmd2.Cmd class so its commands use the custom parser. |
32 |
| -cmd2_parser_module = getattr(argparse, 'cmd2_parser_module', None) |
33 |
| -if cmd2_parser_module is not None: |
34 |
| - import importlib |
35 |
| - |
36 |
| - importlib.import_module(cmd2_parser_module) |
37 |
| - |
38 |
| -from . import plugin |
39 |
| -from .argparse_completer import set_default_ap_completer_type |
40 | 29 | from .cmd2 import Cmd
|
41 |
| -from .command_definition import CommandSet, with_default_category |
42 |
| -from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS |
43 |
| -from .decorators import as_subcommand_to, with_argparser, with_argument_list, with_category |
| 30 | +from .command_definition import ( |
| 31 | + CommandSet, |
| 32 | + with_default_category, |
| 33 | +) |
| 34 | +from .constants import ( |
| 35 | + COMMAND_NAME, |
| 36 | + DEFAULT_SHORTCUTS, |
| 37 | +) |
| 38 | +from .decorators import ( |
| 39 | + as_subcommand_to, |
| 40 | + with_argparser, |
| 41 | + with_argument_list, |
| 42 | + with_category, |
| 43 | +) |
44 | 44 | from .exceptions import (
|
45 | 45 | Cmd2ArgparseError,
|
46 | 46 | CommandSetRegistrationError,
|
|
50 | 50 | )
|
51 | 51 | from .parsing import Statement
|
52 | 52 | from .py_bridge import CommandResult
|
53 |
| -from .utils import CompletionMode, CustomCompletionSettings, Settable, categorize |
| 53 | +from .utils import ( |
| 54 | + CompletionMode, |
| 55 | + CustomCompletionSettings, |
| 56 | + Settable, |
| 57 | + categorize, |
| 58 | +) |
54 | 59 |
|
55 | 60 | __all__: list[str] = [ # noqa: RUF022
|
56 | 61 | 'COMMAND_NAME',
|
|
70 | 75 | 'Cmd2AttributeWrapper',
|
71 | 76 | 'CompletionItem',
|
72 | 77 | 'register_argparse_argument_parameter',
|
73 |
| - 'set_default_argument_parser_type', |
74 | 78 | 'set_default_ap_completer_type',
|
| 79 | + 'set_default_argument_parser_type', |
75 | 80 | # Cmd2
|
76 | 81 | 'Cmd',
|
77 | 82 | 'CommandResult',
|
|
87 | 92 | 'Cmd2ArgparseError',
|
88 | 93 | 'CommandSetRegistrationError',
|
89 | 94 | 'CompletionError',
|
| 95 | + 'PassThroughException', |
90 | 96 | 'SkipPostcommandHooks',
|
91 | 97 | # modules
|
92 | 98 | 'plugin',
|
|
0 commit comments