Skip to content

Commit a3aed05

Browse files
committed
Fixed mypy issues.
1 parent 52a331c commit a3aed05

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

cmd2/argparse_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ def _validate_completion_callable(self: argparse.Action, value: Any) -> Any:
375375
# protocols like copy.deepcopy().
376376
############################################################################################################
377377

378-
# _ColorlessTheme only exists in 3.15+
379-
if hasattr(argparse, "_ColorlessTheme"):
378+
if sys.version_info >= (3, 15):
380379

381380
def _ColorlessTheme_getattr(_self: argparse._ColorlessTheme, name: str) -> Any: # noqa: N802
382381
"""Patched __getattr__ that allows dunder lookups to fail correctly."""

tests/test_argparse_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,13 +750,13 @@ def test_argparse_output_capture(base_app: cmd2.Cmd) -> None:
750750
assert su.strip_style("\n".join(styled_help_out)) == "\n".join(unstyled_help_out)
751751

752752

753+
@pytest.mark.skipif(
754+
sys.version_info < (3, 15),
755+
reason="_ColorlessTheme only exists in 3.15+",
756+
)
753757
def test_colorless_theme_monkeypatch() -> None:
754758
"""Test the _ColorlessTheme.__getattr__ monkey patch."""
755759

756-
# _ColorlessTheme only exists in 3.15+
757-
if not hasattr(argparse, "_ColorlessTheme"):
758-
return
759-
760760
# If this assertion fails, then the bug no longer exists and our patch wasn't installed.
761761
# We can remove the patch function and this test.
762762
assert argparse._ColorlessTheme.__getattr__ == argparse_utils._ColorlessTheme_getattr

0 commit comments

Comments
 (0)