Skip to content

Add type annotations to client.dynamic.Dispatch. - #1022

Merged
junkmd merged 2 commits into
enthought:mainfrom
jeanluyac-sketch:annotate-dynamic-dispatch
Dec 3, 2026
Merged

junkmd merged 2 commits into
enthought:mainfrom
jeanluyac-sketch:annotate-dynamic-dispatch

Conversation

@jeanluyac-sketch

Copy link
Copy Markdown
Contributor

Closes #447

Adds type annotations to client.dynamic.Dispatch using overloads: a _Dispatch is returned as is, an IDispatch pointer yields a _Dispatch or a lazybind.Dispatch, and any other object is returned unchanged. No runtime behaviour changes (the implementation only gains a cast for the type checker).

Checked: ruff format --check passes; pyright --pythonplatform Windows ./ reports one error fewer than before the change (542 -> 541) and none in dynamic.py. I did not run the unittest suite on Windows for this change.

AI assistance: drafted with Claude; I reviewed the diff myself.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137jz1XbSeuomn8S7nSE9k6
@codecov-commenter

codecov-commenter commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.63%. Comparing base (4d68bfa) to head (aeb433a).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1022      +/-   ##
==========================================
+ Coverage   92.62%   92.63%   +0.01%     
==========================================
  Files         154      154              
  Lines       16870    16881      +11     
==========================================
+ Hits        15626    15638      +12     
+ Misses       1244     1243       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread comtypes/client/dynamic.py Resolved
Comment thread comtypes/client/dynamic.py Resolved
@jeanluyac-sketch

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I dropped typing.cast in favor of # type: ignore inside Dispatch, and the overload now annotates the argument as automation.IDispatch (the interface type, as discussed in #957) instead of ctypes._Pointer[...]. Pushed as a new commit.

@junkmd junkmd added the typing related to Python static typing system label Dec 3, 2026
@junkmd junkmd added this to the 1.5.1 milestone Dec 3, 2026

@junkmd junkmd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for taking an interest in static typing here!

Discussions around static typing policies have been pretty rare in this project so far.
Knowing "you're not alone in what you care about" means a lot to maintainers and helps prevent burnout.

@junkmd
junkmd merged commit 33dda10 into enthought:main Dec 3, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typing related to Python static typing system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add type annotations to client.dynamic.Dispatch

4 participants