Skip to content

Refactor completion API#1575

Merged
kmvanbrunt merged 32 commits intomainfrom
refactor_complete
Feb 18, 2026
Merged

Refactor completion API#1575
kmvanbrunt merged 32 commits intomainfrom
refactor_complete

Conversation

@kmvanbrunt
Copy link
Member

Overhauled the completion API to use encapsulation and better reflect how prompt-toolkit works.

- Moved completion classes to new completion.py module.
- Removed all completion state variables from Cmd class and placed them in Completions class.
- All completer functions now return a Completions object.
- Moved completion exception handling to to pt_utils.py.
Removed extra newlines in CompletionErrors and formatted exceptions.
Added display_meta field to CompletionItem.

Added Choices class which is returned by choices_providers.
Added CompletionResultsBase.to_strings().
@github-actions
Copy link
Contributor

🤖 Hi @kmvanbrunt, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 99.60552% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.38%. Comparing base (4482a79) to head (4b40d77).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd2/cmd2.py 98.96% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1575      +/-   ##
==========================================
- Coverage   99.38%   99.38%   -0.01%     
==========================================
  Files          21       22       +1     
  Lines        4910     4902       -8     
==========================================
- Hits         4880     4872       -8     
  Misses         30       30              
Flag Coverage Δ
unittests 99.38% <99.60%> (-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.

@github-actions
Copy link
Contributor

🤖 I'm sorry @kmvanbrunt, but I was unable to process your request. Please see the logs for more details.

tleonhardt
tleonhardt previously approved these changes Feb 18, 2026

return base_set_parser

def complete_set_value(
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how or where the right place to do it is, but I think we should fix how the set completion works in prompt-toolkit. The printed table above looks great.

But if I use the arrow keys to select one of the settables, it shows me the current value. Instead I'd like to see some combination of the current value and help text.

@kmvanbrunt kmvanbrunt changed the title Refactor complete Refactor completion API Feb 18, 2026
@kmvanbrunt kmvanbrunt merged commit ea128a7 into main Feb 18, 2026
54 checks passed
@kmvanbrunt kmvanbrunt deleted the refactor_complete branch February 18, 2026 05:30
@tleonhardt tleonhardt mentioned this pull request Feb 18, 2026
14 tasks
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