Skip to content

chore: Clean up python 2 legacy - #796

Merged
StephenSorriaux merged 1 commit into
python-zk:masterfrom
ThosRTanner:issue/788/cleanup-python-2
Sep 5, 2026
Merged

StephenSorriaux merged 1 commit into
python-zk:masterfrom
ThosRTanner:issue/788/cleanup-python-2

Conversation

@ThosRTanner

@ThosRTanner ThosRTanner commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #788

Remove python2 specific code
Use python 3 style for constructors etc
Use python3.8 techniques in a few places

Why is this needed?

Code cleanup. This moves off deprecated python constructs (such as class X(object))

Proposed Changes

  • Changes class X(object): to class X:
  • changes super(Class, self) to super()
  • removes the strange (python2) handling of EINTR
  • removes from __future__ import absolute_import (an early python 3-ism)
  • other tidyups

Does this PR introduce any breaking change?

No

Coverage changes

These appear to be because it's based on 2 commits ago on master, rather than current master. This change actually increases coverage because there's now coverage of the InterruptedException path in utils.py

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.48%. Comparing base (e894342) to head (e7224a3).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #796      +/-   ##
==========================================
- Coverage   96.65%   95.48%   -1.17%     
==========================================
  Files          27       27              
  Lines        3554     3858     +304     
==========================================
+ Hits         3435     3684     +249     
- Misses        119      174      +55     

☔ 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 issue/788/cleanup-python-2 branch 3 times, most recently from e05442d to 075c81a Compare August 23, 2026 19:36
@StephenSorriaux

Copy link
Copy Markdown
Member

Hey @ThosRTanner, thanks for the PR. I will review it by end of the week. If there is any other issue you would like to work on, please feel free to tackle it; I will have some free time for the next couple of weeks and will be able to be more reactive in my reviews. Thanks again, really appreciate the time you put in this project.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The broad cross-cutting cleanup and differing readiness assessments warrant final human review.

Pull request overview

Modernizes the codebase by removing Python 2 compatibility patterns and adopting Python 3 idioms.

Changes:

  • Simplifies class declarations, super() calls, and comprehensions.
  • Modernizes imports, file handling, subprocess usage, and EINTR handling.
  • Adds coverage for interrupted connection retries.
File summaries
File Description
tox.ini Removes redundant Python declarations.
kazoo/tests/util.py Modernizes tuple and class syntax.
kazoo/tests/test_watchers.py Simplifies superclass calls.
kazoo/tests/test_utils.py Tests interrupted connection retries.
kazoo/tests/test_selectors_select.py Uses subprocess.Popen; obsolete os import remains as a nit.
kazoo/tests/test_party.py Simplifies superclass calls.
kazoo/tests/test_partitioner.py Simplifies superclass calls.
kazoo/tests/test_lock.py Modernizes classes and superclass calls.
kazoo/tests/test_lease.py Modernizes class and superclass syntax.
kazoo/tests/test_gevent_handler.py Uses typed state constants.
kazoo/tests/test_election.py Simplifies superclass calls.
kazoo/tests/test_connection.py Modernizes setup and state comparisons.
kazoo/tests/test_cache.py Simplifies lifecycle calls.
kazoo/testing/harness.py Modernizes tuple and constructor syntax.
kazoo/testing/common.py Modernizes classes and file handling.
kazoo/security.py Modernizes class syntax.
kazoo/retry.py Modernizes class syntax.
kazoo/recipe/watchers.py Modernizes watcher classes.
kazoo/recipe/queue.py Modernizes inheritance calls.
kazoo/recipe/party.py Modernizes class syntax.
kazoo/recipe/lock.py Modernizes synchronization classes.
kazoo/recipe/lease.py Modernizes lease classes.
kazoo/recipe/election.py Modernizes class syntax.
kazoo/recipe/counter.py Modernizes class syntax.
kazoo/recipe/cache.py Removes obsolete compatibility constructs.
kazoo/recipe/barrier.py Modernizes barrier classes.
kazoo/protocol/connection.py Modernizes connection classes.
kazoo/handlers/utils.py Simplifies interrupted-connect handling.
kazoo/handlers/threading.py Removes legacy imports and simplifies super().
kazoo/handlers/gevent.py Removes Python 2 compatibility syntax.
kazoo/handlers/eventlet.py Removes Python 2 compatibility syntax.
kazoo/client.py Modernizes classes and tuple construction.
Review details
  • Files reviewed: 32/32 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread kazoo/tests/test_selectors_select.py Outdated
Fixes python-zk#788

Remove python2 specific code
Use python 3 style for constructors etc
Use python3.8 techniques in a few places
@ThosRTanner
ThosRTanner force-pushed the issue/788/cleanup-python-2 branch from 075c81a to e7224a3 Compare September 4, 2026 06:26

@StephenSorriaux StephenSorriaux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you.

@StephenSorriaux
StephenSorriaux merged commit ede0b0d into python-zk:master Sep 5, 2026
37 of 38 checks passed
@ThosRTanner
ThosRTanner deleted the issue/788/cleanup-python-2 branch September 5, 2026 16:58
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.

There is still python2 ish code in the project

3 participants