Skip to content

Remove six and Python 2 compatibility code#31

Open
s-t-e-v-e-n-k wants to merge 1 commit into
youknowone:mainfrom
s-t-e-v-e-n-k:remove-six
Open

Remove six and Python 2 compatibility code#31
s-t-e-v-e-n-k wants to merge 1 commit into
youknowone:mainfrom
s-t-e-v-e-n-k:remove-six

Conversation

@s-t-e-v-e-n-k

@s-t-e-v-e-n-k s-t-e-v-e-n-k commented Jun 11, 2026

Copy link
Copy Markdown

Now that Python 3.4 is the lowest supported version, we can remove a large amount of code that support versions before it, as well as use of six, as well as the entire _compat module. Drive-by removing the pkg_resources check from setup.py since setuptools 39 is now ten years old.

Summary by CodeRabbit

Release Notes

  • Chores
    • Removed Python 2 and early Python 3 compatibility code and dependencies throughout the project.
    • Simplified internal logic and module initialization by eliminating version-specific workarounds and conditionals.
    • Modernized setup configuration and dependency requirements to focus exclusively on Python 3+ standards.
    • Overall codebase cleanup improves maintainability and reduces complexity.

Now that Python 3.4 is the lowest supported version, we can remove a
large amount of code that support versions before it, as well as use of
six, as well as the entire _compat module. Drive-by removing the
pkg_resources check from setup.py since setuptools 39 is now ten years
old.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR removes Python 2 support from wirerope by eliminating the six and inspect2 dependencies, stripping version-conditional code from callable detection and runtime dispatch, and simplifying build configuration. Runtime logic and type classification are unified to assume Python 3.

Changes

Python 2 compatibility removal

Layer / File(s) Summary
Build configuration and dependency cleanup
setup.cfg, setup.py
install_requires dependencies on six, inspect2, and singledispatch are removed. The setuptools version assertion in setup.py is dropped.
Callable classification method simplification
wirerope/callable.py
Imports switch to standard-library inspect. is_boundmethod, is_barefunction, is_member, and is_classmethod predicates are rewritten to single unified implementations, removing six.PY2/six.PY3/six.PY34 branches and version-specific heuristics.
Runtime dispatch and initialization updates
wirerope/rope.py, wirerope/wire.py
Imports switch to standard-library functools. WireRope.__call__ dispatch simplifies to a single __qualname__ check. Wire.__init__ drops Py2-specific functools.partial attribute handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Python 2 has bid farewell,
No more six or shims to dwell,
Callable methods bloom so bright,
Dispatch logic cleaned up right,
Wirerope hops to Python 3's light! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove six and Python 2 compatibility code' directly and clearly matches the main objective of the PR: eliminating Python 2 compatibility code and removing the six library dependency.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wirerope/callable.py`:
- Line 1: Remove the obsolete Python 2 compatibility import by deleting the line
"from __future__ import absolute_import" at the top of callable.py; no other
code changes required since the project no longer targets Python 2 and this
import has no effect in Python 3.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 75a581b5-b45f-4474-b3e5-de9d061ccb4f

📥 Commits

Reviewing files that changed from the base of the PR and between e5e0576 and 601854d.

📒 Files selected for processing (6)
  • setup.cfg
  • setup.py
  • wirerope/_compat.py
  • wirerope/callable.py
  • wirerope/rope.py
  • wirerope/wire.py
💤 Files with no reviewable changes (3)
  • setup.cfg
  • wirerope/_compat.py
  • setup.py

Comment thread wirerope/callable.py
@@ -1,9 +1,8 @@
from __future__ import absolute_import

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider removing the obsolete __future__ import.

from __future__ import absolute_import has no effect in Python 3. Since this PR removes Python 2 support, this import can be removed for consistency.

🧹 Suggested cleanup
-from __future__ import absolute_import
-
 import inspect
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from __future__ import absolute_import
import inspect
🧰 Tools
🪛 Ruff (0.15.15)

[warning] 1-1: Unnecessary __future__ import absolute_import for target Python version

Remove unnecessary __future__ import

(UP010)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wirerope/callable.py` at line 1, Remove the obsolete Python 2 compatibility
import by deleting the line "from __future__ import absolute_import" at the top
of callable.py; no other code changes required since the project no longer
targets Python 2 and this import has no effect in Python 3.

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.

1 participant