Skip to content

Commit 8b5e5dd

Browse files
committed
Merge branch 'master' into 3.0.0 with fix for documentation autodoc parameters
2 parents 83fbadc + c51ed84 commit 8b5e5dd

11 files changed

+67
-64
lines changed

cmd2/ansi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def clear_screen(clear_type: int = 2) -> str:
164164
2 - clear entire screen
165165
3 - clear entire screen and delete all lines saved in the scrollback buffer
166166
:return: the clear screen string
167-
:raises: ValueError if clear_type is not a valid value
167+
:raises ValueError: if clear_type is not a valid value
168168
"""
169169
if 0 <= clear_type <= 3:
170170
return f"{CSI}{clear_type}J"
@@ -181,7 +181,7 @@ def clear_line(clear_type: int = 2) -> str:
181181
1 - clear from cursor to beginning of the line
182182
2 - clear entire line
183183
:return: the clear line string
184-
:raises: ValueError if clear_type is not a valid value
184+
:raises ValueError: if clear_type is not a valid value
185185
"""
186186
if 0 <= clear_type <= 2:
187187
return f"{CSI}{clear_type}K"
@@ -914,7 +914,7 @@ def __init__(self, r: int, g: int, b: int) -> None:
914914
:param r: integer from 0-255 for the red component of the color
915915
:param g: integer from 0-255 for the green component of the color
916916
:param b: integer from 0-255 for the blue component of the color
917-
:raises: ValueError if r, g, or b is not in the range 0-255
917+
:raises ValueError: if r, g, or b is not in the range 0-255
918918
"""
919919
if any(c < 0 or c > 255 for c in [r, g, b]):
920920
raise ValueError("RGB values must be integers in the range of 0 to 255")
@@ -943,7 +943,7 @@ def __init__(self, r: int, g: int, b: int) -> None:
943943
:param r: integer from 0-255 for the red component of the color
944944
:param g: integer from 0-255 for the green component of the color
945945
:param b: integer from 0-255 for the blue component of the color
946-
:raises: ValueError if r, g, or b is not in the range 0-255
946+
:raises ValueError: if r, g, or b is not in the range 0-255
947947
"""
948948
if any(c < 0 or c > 255 for c in [r, g, b]):
949949
raise ValueError("RGB values must be integers in the range of 0 to 255")
@@ -987,8 +987,8 @@ def style(
987987
:param overline: apply the overline style if True. Defaults to False.
988988
:param strikethrough: apply the strikethrough style if True. Defaults to False.
989989
:param underline: apply the underline style if True. Defaults to False.
990-
:raises: TypeError if fg isn't None or a subclass of FgColor
991-
:raises: TypeError if bg isn't None or a subclass of BgColor
990+
:raises TypeError: if fg isn't None or a subclass of FgColor
991+
:raises TypeError: if bg isn't None or a subclass of BgColor
992992
:return: the stylized string
993993
"""
994994
# list of strings that add style

cmd2/argparse_completer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def complete(
224224
:param cmd_set: if tab completing a command, the CommandSet the command's function belongs to, if applicable.
225225
Defaults to None.
226226
227-
:raises: CompletionError for various types of tab completion errors
227+
:raises CompletionError: for various types of tab completion errors
228228
"""
229229
if not tokens:
230230
return []
@@ -262,7 +262,7 @@ def update_mutex_groups(arg_action: argparse.Action) -> None:
262262
Check if an argument belongs to a mutually exclusive group and either mark that group
263263
as complete or print an error if the group has already been completed
264264
:param arg_action: the action of the argument
265-
:raises: CompletionError if the group is already completed
265+
:raises CompletionError: if the group is already completed
266266
"""
267267
# Check if this action is in a mutually exclusive group
268268
for group in self._parser._mutually_exclusive_groups:
@@ -677,7 +677,7 @@ def _complete_arg(
677677
"""
678678
Tab completion routine for an argparse argument
679679
:return: list of completions
680-
:raises: CompletionError if the completer or choices function this calls raises one
680+
:raises CompletionError: if the completer or choices function this calls raises one
681681
"""
682682
# Check if the arg provides choices to the user
683683
arg_choices: Union[list[str], ChoicesCallable]

cmd2/argparse_custom.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def __init__(self, value: object, description: str = '', *args: Any) -> None:
308308
:param value: the value being tab completed
309309
:param description: description text to display
310310
:param args: args for str __init__
311-
:param kwargs: kwargs for str __init__
312311
"""
313312
super().__init__(*args)
314313
self.description = description
@@ -481,7 +480,7 @@ def _action_set_choices_callable(self: argparse.Action, choices_callable: Choice
481480
482481
:param self: action being edited
483482
:param choices_callable: the ChoicesCallable instance to use
484-
:raises: TypeError if used on incompatible action type
483+
:raises TypeError: if used on incompatible action type
485484
"""
486485
# Verify consistent use of parameters
487486
if self.choices is not None:
@@ -512,7 +511,7 @@ def _action_set_choices_provider(
512511
513512
:param self: action being edited
514513
:param choices_provider: the choices_provider instance to use
515-
:raises: TypeError if used on incompatible action type
514+
:raises TypeError: if used on incompatible action type
516515
"""
517516
self._set_choices_callable(ChoicesCallable(is_completer=False, to_call=choices_provider)) # type: ignore[attr-defined]
518517

@@ -533,7 +532,7 @@ def _action_set_completer(
533532
534533
:param self: action being edited
535534
:param completer: the completer instance to use
536-
:raises: TypeError if used on incompatible action type
535+
:raises TypeError: if used on incompatible action type
537536
"""
538537
self._set_choices_callable(ChoicesCallable(is_completer=True, to_call=completer)) # type: ignore[attr-defined]
539538

@@ -766,7 +765,7 @@ def _add_argument_wrapper(
766765
See the header of this file for more information
767766
768767
:return: the created argument action
769-
:raises: ValueError on incorrect parameter usage
768+
:raises ValueError: on incorrect parameter usage
770769
"""
771770
# Verify consistent use of arguments
772771
choices_callables = [choices_provider, completer]

cmd2/cmd2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ def remove_settable(self, name: str) -> None:
11201120
Convenience method for removing a settable parameter from ``self.settables``
11211121
11221122
:param name: name of the settable being removed
1123-
:raises: KeyError if the Settable matches this name
1123+
:raises KeyError: if the Settable matches this name
11241124
"""
11251125
try:
11261126
del self._settables[name]
@@ -2669,8 +2669,8 @@ def _complete_statement(self, line: str, *, orig_rl_history_length: Optional[int
26692669
This is used to assist in combining multiline readline history entries and is only
26702670
populated by cmd2. Defaults to None.
26712671
:return: the completed Statement
2672-
:raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
2673-
:raises: EmptyStatement when the resulting Statement is blank
2672+
:raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
2673+
:raises EmptyStatement: when the resulting Statement is blank
26742674
"""
26752675

26762676
def combine_rl_history(statement: Statement) -> None:
@@ -3008,7 +3008,7 @@ def read_input(
30083008
:param parser: an argument parser which supports the tab completion of multiple arguments
30093009
30103010
:return: the line read from stdin with all trailing new lines removed
3011-
:raises: any exceptions raised by input() and stdin.readline()
3011+
:raises Exception: any exceptions raised by input() and stdin.readline()
30123012
"""
30133013
readline_configured = False
30143014
saved_completer: Optional[CompleterFunc] = None
@@ -3133,7 +3133,7 @@ def _read_command_line(self, prompt: str) -> str:
31333133
31343134
:param prompt: prompt to display to user
31353135
:return: command line text of 'eof' if an EOFError was caught
3136-
:raises: whatever exceptions are raised by input() except for EOFError
3136+
:raises Exception: whatever exceptions are raised by input() except for EOFError
31373137
"""
31383138
try:
31393139
# Wrap in try since terminal_lock may not be locked
@@ -4802,7 +4802,7 @@ def run_editor(self, file_path: Optional[str] = None) -> None:
48024802
Run a text editor and optionally open a file with it
48034803
48044804
:param file_path: optional path of the file to edit. Defaults to None.
4805-
:raises: EnvironmentError if self.editor is not set
4805+
:raises EnvironmentError: if self.editor is not set
48064806
"""
48074807
if not self.editor:
48084808
raise EnvironmentError("Please use 'set editor' to specify your text editing program of choice.")
@@ -5253,9 +5253,9 @@ def _report_disabled_command_usage(self, *_args: Any, message_to_print: str, **_
52535253
"""
52545254
Report when a disabled command has been run or had help called on it
52555255
5256-
:param args: not used
5256+
:param _args: not used
52575257
:param message_to_print: the message reporting that the command is disabled
5258-
:param kwargs: not used
5258+
:param _kwargs: not used
52595259
"""
52605260
# Set apply_style to False so message_to_print's style is not overridden
52615261
self.perror(message_to_print, apply_style=False)

cmd2/command_definition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _cmd(self) -> 'cmd2.Cmd':
113113
Override this property if you need to change its return type to a
114114
child class of Cmd.
115115
116-
:raises: CommandSetRegistrationError if CommandSet is not registered.
116+
:raises CommandSetRegistrationError: if CommandSet is not registered.
117117
"""
118118
if self.__cmd_internal is None:
119119
raise CommandSetRegistrationError('This CommandSet is not registered')
@@ -126,7 +126,7 @@ def on_register(self, cmd: 'cmd2.Cmd') -> None:
126126
requiring access to the Cmd object (e.g. configure commands and their parsers based on CLI state data).
127127
128128
:param cmd: The cmd2 main application
129-
:raises: CommandSetRegistrationError if CommandSet is already registered.
129+
:raises CommandSetRegistrationError: if CommandSet is already registered.
130130
"""
131131
if self.__cmd_internal is None:
132132
self.__cmd_internal = cmd
@@ -184,7 +184,7 @@ def remove_settable(self, name: str) -> None:
184184
Convenience method for removing a settable parameter from the CommandSet
185185
186186
:param name: name of the settable being removed
187-
:raises: KeyError if the Settable matches this name
187+
:raises KeyError: if the Settable matches this name
188188
"""
189189
try:
190190
del self._settables[name]

cmd2/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def cmd_wrapper(*args: Any, **kwargs: dict[str, Any]) -> Optional[bool]:
351351
contiguously somewhere in the list
352352
:param kwargs: any keyword arguments being passed to command function
353353
:return: return value of command function
354-
:raises: Cmd2ArgparseError if argparse has error parsing command line
354+
:raises Cmd2ArgparseError: if argparse has error parsing command line
355355
"""
356356
cmd2_app, statement_arg = _parse_positionals(args)
357357
statement, parsed_arglist = cmd2_app.statement_parser.get_command_arg_list(

cmd2/parsing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def tokenize(self, line: str) -> list[str]:
323323
324324
:param line: the command line being lexed
325325
:return: A list of tokens
326-
:raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
326+
:raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
327327
"""
328328

329329
# expand shortcuts and aliases
@@ -351,7 +351,7 @@ def parse(self, line: str) -> Statement:
351351
352352
:param line: the command line being parsed
353353
:return: a new [cmd2.parsing.Statement][] object
354-
:raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
354+
:raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation)
355355
"""
356356

357357
# handle the special case/hardcoded terminator of a blank line

cmd2/table_creator.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def __init__(
9090
(defaults to True)
9191
:param max_data_lines: maximum lines allowed in a data cell. If line count exceeds this, then the final
9292
line displayed will be truncated with an ellipsis. (defaults to INFINITY)
93-
:raises: ValueError if width is less than 1
94-
:raises: ValueError if max_data_lines is less than 1
93+
:raises ValueError: if width is less than 1
94+
:raises ValueError: if max_data_lines is less than 1
9595
"""
9696
self.header = header
9797

@@ -136,7 +136,7 @@ def __init__(self, cols: Sequence[Column], *, tab_width: int = 4) -> None:
136136
:param cols: column definitions for this table
137137
:param tab_width: all tabs will be replaced with this many spaces. If a row's fill_char is a tab,
138138
then it will be converted to one space.
139-
:raises: ValueError if tab_width is less than 1
139+
:raises ValueError: if tab_width is less than 1
140140
"""
141141
if tab_width < 1:
142142
raise ValueError("Tab width cannot be less than 1")
@@ -441,9 +441,9 @@ def generate_row(
441441
:param post_line: string to print after each line of a row. This can be used for padding after
442442
the last cell's text and a right row border. (Defaults to blank)
443443
:return: row string
444-
:raises: ValueError if row_data isn't the same length as self.cols
445-
:raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
446-
:raises: ValueError if fill_char, pre_line, inter_cell, or post_line contains an unprintable
444+
:raises ValueError: if row_data isn't the same length as self.cols
445+
:raises TypeError: if fill_char is more than one character (not including ANSI style sequences)
446+
:raises ValueError: if fill_char, pre_line, inter_cell, or post_line contains an unprintable
447447
character like a newline
448448
"""
449449

@@ -568,10 +568,10 @@ def __init__(
568568
want a divider row. Defaults to dash. (Cannot be a line breaking character)
569569
:param header_bg: optional background color for header cells (defaults to None)
570570
:param data_bg: optional background color for data cells (defaults to None)
571-
:raises: ValueError if tab_width is less than 1
572-
:raises: ValueError if column_spacing is less than 0
573-
:raises: TypeError if divider_char is longer than one character
574-
:raises: ValueError if divider_char is an unprintable character
571+
:raises ValueError: if tab_width is less than 1
572+
:raises ValueError: if column_spacing is less than 0
573+
:raises TypeError: if divider_char is longer than one character
574+
:raises ValueError: if divider_char is an unprintable character
575575
"""
576576
super().__init__(cols, tab_width=tab_width)
577577

@@ -624,8 +624,8 @@ def base_width(cls, num_cols: int, *, column_spacing: int = 2) -> int:
624624
:param num_cols: how many columns the table will have
625625
:param column_spacing: how many spaces to place between columns. Defaults to 2.
626626
:return: base width
627-
:raises: ValueError if column_spacing is less than 0
628-
:raises: ValueError if num_cols is less than 1
627+
:raises ValueError: if column_spacing is less than 0
628+
:raises ValueError: if num_cols is less than 1
629629
"""
630630
if num_cols < 1:
631631
raise ValueError("Column count cannot be less than 1")
@@ -683,7 +683,7 @@ def generate_data_row(self, row_data: Sequence[Any]) -> str:
683683
684684
:param row_data: data with an entry for each column in the row
685685
:return: data row string
686-
:raises: ValueError if row_data isn't the same length as self.cols
686+
:raises ValueError: if row_data isn't the same length as self.cols
687687
"""
688688
if len(row_data) != len(self.cols):
689689
raise ValueError("Length of row_data must match length of cols")
@@ -710,7 +710,7 @@ def generate_table(self, table_data: Sequence[Sequence[Any]], *, include_header:
710710
:param include_header: If True, then a header will be included at top of table. (Defaults to True)
711711
:param row_spacing: A number 0 or greater specifying how many blank lines to place between
712712
each row (Defaults to 1)
713-
:raises: ValueError if row_spacing is less than 0
713+
:raises ValueError: if row_spacing is less than 0
714714
"""
715715
if row_spacing < 0:
716716
raise ValueError("Row spacing cannot be less than 0")
@@ -769,8 +769,8 @@ def __init__(
769769
:param border_bg: optional background color for borders (defaults to None)
770770
:param header_bg: optional background color for header cells (defaults to None)
771771
:param data_bg: optional background color for data cells (defaults to None)
772-
:raises: ValueError if tab_width is less than 1
773-
:raises: ValueError if padding is less than 0
772+
:raises ValueError: if tab_width is less than 1
773+
:raises ValueError: if padding is less than 0
774774
"""
775775
super().__init__(cols, tab_width=tab_width)
776776
self.empty_data = [EMPTY] * len(self.cols)
@@ -825,7 +825,7 @@ def base_width(cls, num_cols: int, *, column_borders: bool = True, padding: int
825825
:param column_borders: if True, borders between columns will be included in the calculation (Defaults to True)
826826
:param padding: number of spaces between text and left/right borders of cell
827827
:return: base width
828-
:raises: ValueError if num_cols is less than 1
828+
:raises ValueError: if num_cols is less than 1
829829
"""
830830
if num_cols < 1:
831831
raise ValueError("Column count cannot be less than 1")
@@ -974,7 +974,7 @@ def generate_data_row(self, row_data: Sequence[Any]) -> str:
974974
975975
:param row_data: data with an entry for each column in the row
976976
:return: data row string
977-
:raises: ValueError if row_data isn't the same length as self.cols
977+
:raises ValueError: if row_data isn't the same length as self.cols
978978
"""
979979
if len(row_data) != len(self.cols):
980980
raise ValueError("Length of row_data must match length of cols")
@@ -1075,8 +1075,8 @@ def __init__(
10751075
:param header_bg: optional background color for header cells (defaults to None)
10761076
:param odd_bg: optional background color for odd numbered data rows (defaults to None)
10771077
:param even_bg: optional background color for even numbered data rows (defaults to StdBg.DARK_GRAY)
1078-
:raises: ValueError if tab_width is less than 1
1079-
:raises: ValueError if padding is less than 0
1078+
:raises ValueError: if tab_width is less than 1
1079+
:raises ValueError: if padding is less than 0
10801080
"""
10811081
super().__init__(
10821082
cols,

0 commit comments

Comments
 (0)