Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropping Python 2 support #7367

Closed
srittau opened this issue Feb 23, 2022 · 16 comments · Fixed by #8272
Closed

Dropping Python 2 support #7367

srittau opened this issue Feb 23, 2022 · 16 comments · Fixed by #8272
Labels
project: policy Organization of the typeshed project

Comments

@srittau
Copy link
Collaborator

srittau commented Feb 23, 2022

As far as I'm aware, mypy is the last user of our Python 2 stubs. mypy plans to eventually drop Python 2 support, although no fixed date has been set. See python/mypy#12237 for details. Once mypy has dropped support, we can also consider dropping it. This would ease maintenance and we could simplify our release process quite a bit.

I'm opening and pinning this ticket for discussion and objections.

@srittau srittau added the project: policy Organization of the typeshed project label Feb 23, 2022
@srittau srittau pinned this issue Feb 23, 2022
@srittau
Copy link
Collaborator Author

srittau commented Feb 23, 2022

And as a side note: Python 2 support in third-party packages is being slowly phased out anyway. We dropped all Python 2-only packages that are not required by other packages (with only enum34 and ipaddress left) and we stopped supporting Python 2 in many packages where upstream stopped support for Python 2.

@srittau
Copy link
Collaborator Author

srittau commented Mar 1, 2022

The first step was to drop most Python-2-only third party packages. As a second step I suggest to drop the remaining Python-2-only packages and remove Python 2 support of third-party packages that have separate Python 2 and Python 3 versions. This affects:

  • six
  • ipaddress
  • enum34

This also means dropping Python 2 support for the following packages as they depend on the packages above:

  • cryptography (which is replaced by inline stubs anyway)
  • pyvmomi
  • boto
  • paramiko
  • pysftp

Python 2 support always remains in the current version as published on PyPI, but I think not offering any updates is a reasonable compromise with lowering our maintenance effort.

@Akuli
Copy link
Collaborator

Akuli commented Mar 1, 2022

I think Python 2 support for six stubs should be dropped last, as six users typically care about Python 2.

@srittau
Copy link
Collaborator Author

srittau commented Mar 1, 2022

We had one non-maintenance commit since the re-org more than a year ago, but two maintenance commits. types-six 1.16.10 is not going away, but the maintenance burden remains. I believe that six is nowadays often used, just because removing it from Python 3 code is effort.

Edit: One of my motiviations is to get rid of @python2 special handling here and in the stub uploader.

srittau added a commit to srittau/typeshed that referenced this issue Mar 9, 2022
* Remove all Python 2 only third-party distributions.
* Remove Python 2 support from six as the Python 2 stubs diverged from
  the Python 3 stubs.
* Recursively remove Python 2 support from all distributions that depend
  on the distributions above.

Affects:

* boto
* cryptography
* enum34 (removed)
* ipaddress (removed)
* paramiko
* pysftp
* pyvmomi
* six

Part of python#7367
@hauntsaninja
Copy link
Collaborator

Would it make sense to remove six altogether? Seems unlikely that six's API would change much and it feels a little weird and potentially confusing for users to have types-six not support Python 2.

@srittau
Copy link
Collaborator Author

srittau commented Mar 9, 2022

I have no strong feelings about six. Last release was less than a year ago, though.

AlexWaygood added a commit that referenced this issue Mar 31, 2022
We should hopefully be getting rid of this entire subdirectory soon anyway (#7367). This will make PRs to flake8-pyi a lot easier.
AlexWaygood added a commit that referenced this issue Mar 31, 2022
We should hopefully be getting rid of this entire subdirectory soon anyway (#7367). This will make PRs to flake8-pyi a lot easier.
@srittau
Copy link
Collaborator Author

srittau commented Apr 16, 2022

The next step would be to drop Python 2 support from the remaining third-party stubs. This affects:

  • atomicwrites
  • backports.ssl_match_hostname
  • certifi
  • characteristic
  • chardet
  • click-spinner
  • colorama
  • croniter
  • Deprecated
  • docopt
  • emoji
  • entrypoints
  • first
  • mypy-extensions
  • polib
  • pyaudio
  • python-dateutil
  • python-gflags
  • python-nmap
  • pytz
  • retry
  • simplejson
  • singledispatch
  • tabulate
  • termcolor
  • toml
  • xxhash

This would ease maintenance a bit more, since we don't have to take care not to break Python 2 when updating those stubs and we could remove Python 2 support from the stub uploader. As before, the current version of the stubs will remain on PyPI indefinitely and can be used for people still using Python 2, but updates to the stubs (for Python 2) won't be possible anymore.

@AlexWaygood
Copy link
Member

AlexWaygood commented Apr 16, 2022

Would it make sense to remove six altogether? Seems unlikely that six's API would change much and it feels a little weird and potentially confusing for users to have types-six not support Python 2.

I think we should keep six around for a little while longer. Dropbox is apparently not using Python 2 anymore, but (reading between the lines) is evidently still using six:

So it seems likely that removing six stubs would be fairly disruptive.

@srittau
Copy link
Collaborator Author

srittau commented Apr 16, 2022

Yes, I believe that even users that have dropped Python 2 might still use six as replacing it with native Python 3 calls is work and a risk to introduce new bugs. (Although it's also technical debt.)

@AlexWaygood
Copy link
Member

The next step would be to drop Python 2 support from the remaining third-party stubs.

Doing this would also mean we could enable several flake8-pyi checks that currently don't run on third-party stubs (because some of them still support Python 2).

@JukkaL
Copy link
Contributor

JukkaL commented Apr 18, 2022

six is still one of the top 10 most downloaded packages on PyPI, according to https://hugovk.github.io/top-pypi-packages/. I wouldn't be surprised if six will continue to be used even after years from now, since tech debt cleanup tends to get postponed. Continuing to maintain the stubs seems useful to me.

@srittau
Copy link
Collaborator Author

srittau commented May 4, 2022

This only leaves support for the stdlib, which we can drop after mypy drop Python 2 support (python/mypy#12237).

@ethanhs
Copy link
Contributor

ethanhs commented May 19, 2022

I was running the mypy test suite and I discovered that I am the only one foolish enough to keep Python 2 kicking around on their system to get picked up by mypy's test suite.

I ran

pytest mypy/test/testpythoneval.py::PythonEvaluationSuite::python2eval.test

And all of the Python 2 tests run against typeshed failed due to an incompatibility with __or__ and __ior__ between MutableSet and AbstractSet.

This seems to have broken in mypy's 0.950 release, I haven't tracked it to which commit. I know it is after this mypy typeshed sync

I personally don't really think it is worth the effort to fix this, I just uninstalled Python 2, but if someone else cares enough to fix it I figured I should report it.

@AlexWaygood
Copy link
Member

AlexWaygood commented May 19, 2022

It was probably this PR that broke things:

The PR was made to unblock some changes over at our linter, flake8-pyi. We no longer run flake8-pyi on the Python 2 stdlib, however, so we could probably just revert that PR fairly easily.

@srittau
Copy link
Collaborator Author

srittau commented May 19, 2022

I'm fine with reverting, although I'd say we wait on mypy to decide whether they still want to support Python 2 in 0.960 and just remove the @python2 tree if they don't.

JukkaL added a commit to JukkaL/typeshed that referenced this issue May 20, 2022
Similar errors are already ignored in Python 3 stubs. The
errors break Python 2 tests of mypy.

See python#7367 (comment)
for context.
AlexWaygood pushed a commit that referenced this issue May 20, 2022
Similar errors are already ignored in Python 3 stubs. The
errors break Python 2 tests of mypy.

See #7367 (comment)
for context.
@AlexWaygood
Copy link
Member

Mypy is now ready for us to remove support for Python 2: python/mypy#12237 (comment)

Who wants to do the honours?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants