From e558e4b3a6590c7c2335c92e67b8d8dbda74a5a2 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 9 Jul 2026 10:44:40 -0400 Subject: [PATCH 1/2] Fixed mypy 2.2.0 failures mypy 2.2.0 updated its typeshed definitions for argparse.ArgumentParser to align with recent updates to the standard library in newer Python versions (such as the addition of the file argument for output coloring and the optional formatter parameter). These new type stub signatures broke our overrides in cmd2/argparse_utils.py: - _get_formatter failed because the typeshed stub specifies it can accept an optional parameter file positionally, but our override only captured keyword arguments (**_kwargs: Any). - format_help failed because our override strictly took no arguments (def format_help(self)), while the base class accepts formatter. --- cmd2/argparse_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd2/argparse_utils.py b/cmd2/argparse_utils.py index 6a90b9c89..f58128167 100644 --- a/cmd2/argparse_utils.py +++ b/cmd2/argparse_utils.py @@ -1035,13 +1035,13 @@ def error(self, message: str) -> NoReturn: self.exit(2, f"{formatted_message}\n") - def _get_formatter(self, **_kwargs: Any) -> Cmd2HelpFormatter: + def _get_formatter(self, *_args: Any, **_kwargs: Any) -> Cmd2HelpFormatter: """Override with customizations for Cmd2HelpFormatter.""" return self.formatter_class(prog=self.prog, file=self._thread_locals.current_output_file) - def format_help(self) -> str: + def format_help(self, *args: Any, **kwargs: Any) -> str: """Override to add a newline.""" - return super().format_help() + "\n" + return super().format_help(*args, **kwargs) + "\n" def _get_nargs_pattern(self, action: argparse.Action) -> str: """Override to support nargs ranges.""" From d5bfb7f801433f4902b11622a8061e27662085c5 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 9 Jul 2026 12:27:44 -0400 Subject: [PATCH 2/2] Updated CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d618b0ec..dd3e00d99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.1.1 (TBD) + +- Bug Fixes + - Fixed a couple type issues that emerged with the upgrade to `mypy` 2.2.0 + ## 4.1.0 (July 7, 2026) - Breaking Changes