From 35108eb423113fe7caf6dc5b76fe9aee1fe6f01c Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 21 Aug 2025 00:59:28 -0400 Subject: [PATCH] Corrected a comment and some type hints. --- cmd2/argparse_custom.py | 6 +++--- cmd2/rich_utils.py | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index 4f0e99f60..73a1aa466 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -1261,7 +1261,7 @@ def _format_action_invocation(self, action: argparse.Action) -> str: def _determine_metavar( self, action: argparse.Action, - default_metavar: str | tuple[str, ...], + default_metavar: str, ) -> str | tuple[str, ...]: """Determine what to use as the metavar value of an action.""" if action.metavar is not None: @@ -1278,7 +1278,7 @@ def _determine_metavar( def _metavar_formatter( self, action: argparse.Action, - default_metavar: str | tuple[str, ...], + default_metavar: str, ) -> Callable[[int], tuple[str, ...]]: metavar = self._determine_metavar(action, default_metavar) @@ -1289,7 +1289,7 @@ def format_tuple(tuple_size: int) -> tuple[str, ...]: return format_tuple - def _format_args(self, action: argparse.Action, default_metavar: str | tuple[str, ...]) -> str: + def _format_args(self, action: argparse.Action, default_metavar: str) -> str: """Handle ranged nargs and make other output less verbose.""" metavar = self._determine_metavar(action, default_metavar) metavar_formatter = self._metavar_formatter(action, default_metavar) diff --git a/cmd2/rich_utils.py b/cmd2/rich_utils.py index 95cd431d0..05ef523b2 100644 --- a/cmd2/rich_utils.py +++ b/cmd2/rich_utils.py @@ -128,13 +128,11 @@ def __init__(self, file: IO[str] | None = None) -> None: elif ALLOW_STYLE == AllowStyle.NEVER: force_terminal = False - # Configure console defaults to treat output as plain, unstructured text. - # This involves enabling soft wrapping (no automatic word-wrap) and disabling - # Rich's automatic markup, emoji, and highlight processing. - # While these automatic features are off by default, the console fully supports - # rendering explicitly created Rich objects (e.g., Panel, Table). - # Any of these default settings or other print behaviors can be overridden - # in individual Console.print() calls or via cmd2's print methods. + # The console's defaults are configured to handle pre-formatted text. It enables soft wrap, + # which prevents automatic word-wrapping, and disables Rich's automatic processing for + # markup, emoji, and highlighting. While these features are off by default, the console + # can still fully render explicit Rich objects like Panels and Tables. These defaults can + # be overridden in calls to Cmd2Console.print() and cmd2's print methods. super().__init__( file=file, force_terminal=force_terminal,