Skip to content

Commit 96a5cad

Browse files
committed
The latest version of Ruff has some improved string formatting, run auto-format to fix that
1 parent dac5891 commit 96a5cad

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

cmd2/argparse_custom.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,11 @@ def _action_set_choices_callable(self: argparse.Action, choices_callable: Choice
477477
"""
478478
# Verify consistent use of parameters
479479
if self.choices is not None:
480-
err_msg = "None of the following parameters can be used alongside a choices parameter:\n" "choices_provider, completer"
480+
err_msg = "None of the following parameters can be used alongside a choices parameter:\nchoices_provider, completer"
481481
raise (TypeError(err_msg))
482482
elif self.nargs == 0:
483483
err_msg = (
484-
"None of the following parameters can be used on an action that takes no arguments:\n"
485-
"choices_provider, completer"
484+
"None of the following parameters can be used on an action that takes no arguments:\nchoices_provider, completer"
486485
)
487486
raise (TypeError(err_msg))
488487

@@ -766,7 +765,7 @@ def _add_argument_wrapper(
766765
num_params_set = len(choices_callables) - choices_callables.count(None)
767766

768767
if num_params_set > 1:
769-
err_msg = "Only one of the following parameters may be used at a time:\n" "choices_provider, completer"
768+
err_msg = "Only one of the following parameters may be used at a time:\nchoices_provider, completer"
770769
raise (ValueError(err_msg))
771770

772771
# Pre-process special ranged nargs

cmd2/cmd2.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class Cmd(cmd.Cmd):
305305
DEFAULT_EDITOR = utils.find_editor()
306306

307307
INTERNAL_COMMAND_EPILOG = (
308-
"Notes:\n" " This command is for internal use and is not intended to be called from the\n" " command line."
308+
"Notes:\n This command is for internal use and is not intended to be called from the\n command line."
309309
)
310310

311311
# Sorting keys for strings
@@ -3380,8 +3380,8 @@ def _cmdloop(self) -> None:
33803380
#############################################################
33813381

33823382
# Top-level parser for alias
3383-
alias_description = "Manage aliases\n" "\n" "An alias is a command that enables replacement of a word by another string."
3384-
alias_epilog = "See also:\n" " macro"
3383+
alias_description = "Manage aliases\n\nAn alias is a command that enables replacement of a word by another string."
3384+
alias_epilog = "See also:\n macro"
33853385
alias_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=alias_description, epilog=alias_epilog)
33863386
alias_parser.add_subparsers(metavar='SUBCOMMAND', required=True)
33873387

@@ -3548,8 +3548,8 @@ def _alias_list(self, args: argparse.Namespace) -> None:
35483548
#############################################################
35493549

35503550
# Top-level parser for macro
3551-
macro_description = "Manage macros\n" "\n" "A macro is similar to an alias, but it can contain argument placeholders."
3552-
macro_epilog = "See also:\n" " alias"
3551+
macro_description = "Manage macros\n\nA macro is similar to an alias, but it can contain argument placeholders."
3552+
macro_epilog = "See also:\n alias"
35533553
macro_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=macro_description, epilog=macro_epilog)
35543554
macro_parser.add_subparsers(metavar='SUBCOMMAND', required=True)
35553555

@@ -3806,7 +3806,7 @@ def complete_help_subcommands(
38063806
return completer.complete_subcommand_help(text, line, begidx, endidx, arg_tokens['subcommands'])
38073807

38083808
help_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
3809-
description="List available commands or provide " "detailed help for a specific command"
3809+
description="List available commands or provide detailed help for a specific command"
38103810
)
38113811
help_parser.add_argument(
38123812
'-v', '--verbose', action='store_true', help="print a list of all commands with descriptions of each"
@@ -4699,22 +4699,22 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]: # pragma: no cover
46994699

47004700
history_format_group = history_parser.add_argument_group(title='formatting')
47014701
history_format_group.add_argument(
4702-
'-s', '--script', action='store_true', help='output commands in script format, i.e. without command\n' 'numbers'
4702+
'-s', '--script', action='store_true', help='output commands in script format, i.e. without command\nnumbers'
47034703
)
47044704
history_format_group.add_argument(
47054705
'-x',
47064706
'--expanded',
47074707
action='store_true',
4708-
help='output fully parsed commands with any aliases and\n' 'macros expanded, instead of typed commands',
4708+
help='output fully parsed commands with any aliases and\nmacros expanded, instead of typed commands',
47094709
)
47104710
history_format_group.add_argument(
47114711
'-v',
47124712
'--verbose',
47134713
action='store_true',
4714-
help='display history and include expanded commands if they\n' 'differ from the typed command',
4714+
help='display history and include expanded commands if they\ndiffer from the typed command',
47154715
)
47164716
history_format_group.add_argument(
4717-
'-a', '--all', action='store_true', help='display all commands, including ones persisted from\n' 'previous sessions'
4717+
'-a', '--all', action='store_true', help='display all commands, including ones persisted from\nprevious sessions'
47184718
)
47194719

47204720
history_arg_help = (
@@ -5189,7 +5189,7 @@ def do_run_script(self, args: argparse.Namespace) -> Optional[bool]:
51895189
"interpreted relative to the already-running script's directory."
51905190
)
51915191

5192-
relative_run_script_epilog = "Notes:\n" " This command is intended to only be used within text file scripts."
5192+
relative_run_script_epilog = "Notes:\n This command is intended to only be used within text file scripts."
51935193

51945194
relative_run_script_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
51955195
description=relative_run_script_description, epilog=relative_run_script_epilog
@@ -5671,7 +5671,7 @@ def _validate_prepostcmd_hook(
56715671
raise TypeError(f'{func.__name__} does not have a declared return type, expected {data_type}')
56725672
if signature.return_annotation != data_type:
56735673
raise TypeError(
5674-
f'{func.__name__} has incompatible return type {signature.return_annotation}, expected ' f'{data_type}'
5674+
f'{func.__name__} has incompatible return type {signature.return_annotation}, expected {data_type}'
56755675
)
56765676

56775677
def register_precmd_hook(self, func: Callable[[plugin.PrecommandData], plugin.PrecommandData]) -> None:

examples/argparse_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def choices_arg_tokens(self, arg_tokens: Dict[str, List[str]]) -> List[str]:
6868

6969
# Parser for example command
7070
example_parser = Cmd2ArgumentParser(
71-
description="Command demonstrating tab completion with argparse\n" "Notice even the flags of this command tab complete"
71+
description="Command demonstrating tab completion with argparse\nNotice even the flags of this command tab complete"
7272
)
7373

7474
# Tab complete from a list using argparse choices. Set metavar if you don't

examples/modular_commands_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def choices_provider(self) -> List[str]:
4141

4242
# Parser for example command
4343
example_parser = Cmd2ArgumentParser(
44-
description="Command demonstrating tab completion with argparse\n" "Notice even the flags of this command tab complete"
44+
description="Command demonstrating tab completion with argparse\nNotice even the flags of this command tab complete"
4545
)
4646

4747
# Tab complete from a list using argparse choices. Set metavar if you don't

examples/table_creation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ def basic_tables():
7777

7878
# Table data which demonstrates handling of wrapping and text styles
7979
data_list: List[List[Any]] = list()
80-
data_list.append(["Billy Smith", "123 Sesame St.\n" "Fake Town, USA 33445", DollarFormatter(100333.03)])
80+
data_list.append(["Billy Smith", "123 Sesame St.\nFake Town, USA 33445", DollarFormatter(100333.03)])
8181
data_list.append(
8282
[
8383
"William Longfellow Marmaduke III",
84-
"984 Really Long Street Name Which Will Wrap Nicely\n" "Apt 22G\n" "Pensacola, FL 32501",
84+
"984 Really Long Street Name Which Will Wrap Nicely\nApt 22G\nPensacola, FL 32501",
8585
DollarFormatter(55135.22),
8686
]
8787
)
8888
data_list.append(
8989
[
9090
"James " + blue("Bluestone"),
91-
bold_yellow("This address has line feeds,\n" "text styles, and wrapping. ")
91+
bold_yellow("This address has line feeds,\ntext styles, and wrapping. ")
9292
+ blue("Style is preserved across lines."),
9393
DollarFormatter(300876.10),
9494
]

0 commit comments

Comments
 (0)