Skip to content

Remove Python 2 compatibility shims#2771

Merged
dyf merged 1 commit into
AllenInstitute:masterfrom
galenlynch:fix/remove-six
Feb 17, 2026
Merged

Remove Python 2 compatibility shims#2771
dyf merged 1 commit into
AllenInstitute:masterfrom
galenlynch:fix/remove-six

Conversation

@galenlynch
Copy link
Copy Markdown
Contributor

Overview:

six and future are Python 2 compatibility shims. Python 3 was released 18 years ago. AllenSDK now requires Python 3.10+. Time to stop using Python 2.

Addresses:

Drop 18+ year old python code.

Type of Fix:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
  • Documentation Change

Solution:

Remove all Python 2 compatibility shims (six and future packages) and replace with stdlib equivalents.

Changes:

Remove all import six / from six import ... / from past.builtins import ...
across the codebase and replace with stdlib equivalents:

Pattern Replacement
six.iteritems(d) d.items()
six.itervalues(d) d.values()
six.string_types str
six.text_type str
six.moves.xrange range
six.moves.reduce functools.reduce
six.moves.builtins builtins
six.moves.cPickle pickle
six.raise_from(X, e) raise X from e
six.ensure_str(s) s (already str in Python 3)
past.builtins.xrange range

Drop six and future from pyproject.toml dependencies.

Validation:

  • pytest: 2484 passed, 207 skipped, 1 xfailed, 0 failures
  • Notebooks: 30/30 passed
  • Tested with Python 3.13 in a clean venv

Checklist

  • My code follows
    Allen Institute Contribution Guidelines
  • My code is unit tested and does not decrease test coverage
  • I have performed a self review of my own code
  • My code is well-documented, and the docstrings conform to
    Numpy Standards
  • I have updated the documentation of the repository where
    appropriate
  • The header on my commit includes the issue number
  • My Pull Request has the latest AllenSDK release candidate branch
    rc/x.y.z as its merge target
  • My code passes all AllenSDK tests

Remove all Python 2 compatibility shims (six and future packages)
and replace with stdlib equivalents:

- six.iteritems(d) → d.items()
- six.itervalues(d) → d.values()
- six.string_types → str
- six.text_type → str
- six.moves.xrange → range
- six.moves.reduce → functools.reduce
- six.moves.builtins → builtins
- six.moves.cPickle → pickle
- six.raise_from(X, e) → raise X from e
- six.ensure_str(s) → s
- past.builtins.xrange → range

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@galenlynch galenlynch changed the title Remove six and future Remove Python 2 compatibility shims Feb 16, 2026
@dyf dyf merged commit 920f18e into AllenInstitute:master Feb 17, 2026
4 of 6 checks passed
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