Skip to content

chore: improve cmd2 maintenance path#1669

Open
lphuc2250gma wants to merge 1 commit into
python-cmd2:mainfrom
lphuc2250gma:maint/20260524201955
Open

chore: improve cmd2 maintenance path#1669
lphuc2250gma wants to merge 1 commit into
python-cmd2:mainfrom
lphuc2250gma:maint/20260524201955

Conversation

@lphuc2250gma
Copy link
Copy Markdown

Summary:

  • Add focused edge-case unit tests in tests/test_utils.py for small pure helpers in cmd2/utils.py (e.g., quote/unquote, alphabetical_sort, str_to_bool, strip_ansi handling of empty/None/whitespace inputs and mixed-quote tokens), and tighten one or two narrow type annotations where Optional/Union is currently broader than the implementation requires.
  • Keep the change narrow so it is straightforward to review.

Notes:

  • I kept this scoped to the relevant implementation and tests.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.53%. Comparing base (e2c061c) to head (ad67406).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1669      +/-   ##
==========================================
- Coverage   99.53%   99.53%   -0.01%     
==========================================
  Files          22       22              
  Lines        4928     4903      -25     
==========================================
- Hits         4905     4880      -25     
  Misses         23       23              
Flag Coverage Δ
unittests 99.53% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread cmd2/utils.py
def __init__(
self,
inner_stream: Union[TextIO, "StdSim"],
inner_stream: TextIO | "StdSim",
Copy link
Copy Markdown
Member

@tleonhardt tleonhardt May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the upcoming cmd2 4.0.0 release we support Python versions 3.11 or newer.

Using the | operator with a forward-declaration string type works with Python 3.14+, but does not work with older versions of Python, hence the Union is still required for forward declaration types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants