Skip to content

Migrate away from six for Python 3.10+ - #341

Merged
YonathanZetune merged 3 commits into
google:masterfrom
AleksMat:master
Dec 2, 2026
Merged

YonathanZetune merged 3 commits into
google:masterfrom
AleksMat:master

Conversation

@AleksMat

@AleksMat AleksMat commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

six is a Python 2/3 compatibility shim that is no longer needed once the package targets Python 3.10 and newer.

Drop Python 2 and pre-3.10 compatibility and remove all six usage:

  • Replace six types, helpers, and six.moves imports with native Python 3 syntax and standard library modules (builtins, collections.abc, http.client, io, urllib, metaclass=, raise ...with_traceback(...), dict.items()/values(), str, bytes, int, type, chr).
  • Subclass enum.EnumType in protorpclite.messages._EnumClass and declare name: str and number: int on Enum instances under typing.TYPE_CHECKING so static type checkers recognize messages.Enum subclasses as enum types instead of treating member values as int once six.with_metaclass is removed.
  • Remove six.PY2/six.PY3 branches, obsolete Python 2 long checks, and remaining from __future__ import print_function imports.
  • Drop six from setup.py and tox.ini, set python_requires to >=3.10, remove obsolete Python 2 and 3.5 classifiers, and update .travis.yml for Python 3.10.

`six` is a Python 2/3 compatibility shim that is no longer needed once
the package targets Python 3.11 and newer.

Drop Python 2 and pre-3.11 compatibility and remove all `six` usage:

- Replace `six` types, helpers, and `six.moves` imports with native
  Python 3 syntax and standard library modules (`builtins`,
  `collections.abc`, `http.client`, `io`, `urllib`, `metaclass=`,
  `raise ...with_traceback(...)`, `dict.items()`/`values()`, `str`,
  `bytes`, `int`, `type`, `chr`).
- Subclass `enum.EnumType` in `protorpclite.messages._EnumClass` and
  declare `name: str` and `number: int` on `Enum` instances under
  `typing.TYPE_CHECKING` so static type checkers recognize
  `messages.Enum` subclasses as enum types instead of treating member
  values as `int` once `six.with_metaclass` is removed.
- Remove `six.PY2`/`six.PY3` branches, obsolete Python 2 `long` checks,
  and remaining `from __future__ import print_function` imports.
- Drop `six` from `setup.py` and `tox.ini`, set `python_requires` to
  `>=3.11`, remove obsolete Python 2 and 3.5 classifiers, and update
  `.travis.yml` for Python 3.11.
Python 3.11 introduced `enum.EnumType` (keeping `enum.EnumMeta` as an
alias), so type checking against Python 3.10 fails to resolve
`enum.EnumType` in typeshed. In addition, Google Cloud CLI still
supports Python 3.10 through 3.15.

- Replace `enum.EnumType` with `enum.EnumMeta` in
  `apitools/base/protorpclite/messages.py` under `typing.TYPE_CHECKING`
  for compatibility across Python 3.10 through 3.15.
- Lower `python_requires` in `setup.py` from `>=3.11` to `>=3.10`.
Update `.travis.yml` to align the CI matrix and `tox` environments with
the lowered `python_requires='>=3.10'` requirement in `setup.py`.

- Change the matrix `python` version from `"3.11"` to `"3.10"`.
- Update `TOX_ENV` entries and the `after_success` `coveralls` check
  from `py311-oauth2client*` to `py310-oauth2client*`.
@AleksMat AleksMat changed the title Migrate away from six for Python 3.11+ Migrate away from six for Python 3.10+ Dec 2, 2026
@YonathanZetune
YonathanZetune self-requested a review December 2, 2026 21:06
@YonathanZetune
YonathanZetune merged commit 326ea73 into google:master Dec 2, 2026
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