Repository navigation
Migrate away from six for Python 3.10+ - #341
Merged
Merged
Conversation
`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*`.
YonathanZetune
self-requested a review
December 2, 2026 21:06
YonathanZetune
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sixis 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
sixusage:sixtypes, helpers, andsix.movesimports 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).enum.EnumTypeinprotorpclite.messages._EnumClassand declarename: strandnumber: intonEnuminstances undertyping.TYPE_CHECKINGso static type checkers recognizemessages.Enumsubclasses as enum types instead of treating member values asintoncesix.with_metaclassis removed.six.PY2/six.PY3branches, obsolete Python 2longchecks, and remainingfrom __future__ import print_functionimports.sixfromsetup.pyandtox.ini, setpython_requiresto>=3.10, remove obsolete Python 2 and 3.5 classifiers, and update.travis.ymlfor Python 3.10.