Skip to content

Typing cleanups 2 - Make all the handlers inherit from IHandler protocol to remove casts, consolidate tests. - #829

Draft
ThosRTanner wants to merge 10 commits into
python-zk:masterfrom
ThosRTanner:typing_cleanups_2
Draft

ThosRTanner wants to merge 10 commits into
python-zk:masterfrom
ThosRTanner:typing_cleanups_2

Conversation

@ThosRTanner

@ThosRTanner ThosRTanner commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #828 (oddly)

Depends on #801

Why is this needed?

This makes the type checking safer and allows us to remove a lot of casting.

Proposed Changes

  • Make all the SequentialHandlers inherit from the IHandler Protocol
  • Clean up the IAsyncResult protocol and uses of it.
  • ...

Does this PR introduce any breaking change?

Potentially, yes. It is no longer possible to pass a string to IHandler.timeout_exception - note that when this was used with gevent handlers, the string gets discarded, but it also meant that timeouts on the get and get_nowait methods in IAsyncHandler could throw an unexpected exception (gevent.Timeout, not the IHandler.timeout_exception, which returned a wrapper).

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.22179% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.57%. Comparing base (f54c4fd) to head (a49cd39).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
kazoo/handlers/gevent.py 96.55% 1 Missing ⚠️
kazoo/protocol/connection.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #829      +/-   ##
==========================================
+ Coverage   94.90%   96.57%   +1.66%     
==========================================
  Files          27       27              
  Lines        3811     3737      -74     
==========================================
- Hits         3617     3609       -8     
+ Misses        194      128      -66     

☔ 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.

@ThosRTanner
ThosRTanner force-pushed the typing_cleanups_2 branch 3 times, most recently from d0d5e83 to 03b8760 Compare October 31, 2026 16:51
@ceache

ceache commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

I like cleanup too, thanks for this.
Could you make sure the commit message follow the guideline.

I would also prefer if you put the content in the commit message itself instead of referring to the PR.

E.g. "chore(typing): clean up some of the workarounds from the initial PR
See PR for details
"

Git commit log is our true history, not so much github PRs.

@ceache

ceache commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

There is also opportunity for squashing a couple of these commits, I think.

@ThosRTanner

Copy link
Copy Markdown
Contributor Author

I like cleanup too, thanks for this. Could you make sure the commit message follow the guideline.

I would also prefer if you put the content in the commit message itself instead of referring to the PR.

E.g. "chore(typing): clean up some of the workarounds from the initial PR See PR for details "

Git commit log is our true history, not so much github PRs.

Yeah, sorry, nowhere near finished on this. hence why it's draft

@ThosRTanner
ThosRTanner force-pushed the typing_cleanups_2 branch 3 times, most recently from 6968621 to a49cd39 Compare November 19, 2026 12:34
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.

The unit tests for the 3 sequential handlers should be consolidated.

2 participants