|
12 | 12 | from typing import (
|
13 | 13 | TYPE_CHECKING,
|
14 | 14 | Optional,
|
15 |
| - Type, |
16 | 15 | Union,
|
17 | 16 | cast,
|
18 | 17 | )
|
@@ -143,11 +142,9 @@ def __init__(self, flag_arg_state: _ArgumentState) -> None:
|
143 | 142 | CompletionError which occurs when the user has not finished the current flag
|
144 | 143 | :param flag_arg_state: information about the unfinished flag action
|
145 | 144 | """
|
146 |
| - error = "Error: argument {}: {} ({} entered)".format( |
147 |
| - argparse._get_action_name(flag_arg_state.action), |
148 |
| - generate_range_error(cast(int, flag_arg_state.min), cast(Union[int, float], flag_arg_state.max)), |
149 |
| - flag_arg_state.count, |
150 |
| - ) |
| 145 | + arg = f'{argparse._get_action_name(flag_arg_state.action)}' |
| 146 | + err = f'{generate_range_error(cast(int, flag_arg_state.min), cast(Union[int, float], flag_arg_state.max))}' |
| 147 | + error = f"Error: argument {arg}: {err} ({flag_arg_state.count} entered)" |
151 | 148 | super().__init__(error)
|
152 | 149 |
|
153 | 150 |
|
@@ -272,9 +269,9 @@ def update_mutex_groups(arg_action: argparse.Action) -> None:
|
272 | 269 | if arg_action == completer_action:
|
273 | 270 | return
|
274 | 271 |
|
275 |
| - error = "Error: argument {}: not allowed with argument {}".format( |
276 |
| - argparse._get_action_name(arg_action), argparse._get_action_name(completer_action) |
277 |
| - ) |
| 272 | + arg_str = f'{argparse._get_action_name(arg_action)}' |
| 273 | + completer_str = f'{argparse._get_action_name(completer_action)}' |
| 274 | + error = f"Error: argument {arg_str}: not allowed with argument {completer_str}" |
278 | 275 | raise CompletionError(error)
|
279 | 276 |
|
280 | 277 | # Mark that this action completed the group
|
@@ -766,10 +763,10 @@ def _complete_arg(
|
766 | 763 |
|
767 | 764 |
|
768 | 765 | # The default ArgparseCompleter class for a cmd2 app
|
769 |
| -DEFAULT_AP_COMPLETER: Type[ArgparseCompleter] = ArgparseCompleter |
| 766 | +DEFAULT_AP_COMPLETER: type[ArgparseCompleter] = ArgparseCompleter |
770 | 767 |
|
771 | 768 |
|
772 |
| -def set_default_ap_completer_type(completer_type: Type[ArgparseCompleter]) -> None: |
| 769 | +def set_default_ap_completer_type(completer_type: type[ArgparseCompleter]) -> None: |
773 | 770 | """
|
774 | 771 | Set the default ArgparseCompleter class for a cmd2 app.
|
775 | 772 |
|
|
0 commit comments