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

Python 2 feature freeze (and removal of support) #12237

Closed
JukkaL opened this issue Feb 22, 2022 · 22 comments
Closed

Python 2 feature freeze (and removal of support) #12237

JukkaL opened this issue Feb 22, 2022 · 22 comments
Labels
meta Issues tracking a broad area of work topic-python2 issues only applicable to Python 2

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 22, 2022

Since Python 2 reached its EOL Jan 1 2020 (over two years ago), I think that it's time to not actively improve Python 2 support any more.

Details:

  1. We won't accept new PRs that improve Python 2 support, unless they fix a significant regression.
  2. We won't drop or degrade existing support for Python 2, for now. Python 2 will become unsupported at some point, but at least not until the second half of 2022 (details TBD).
  3. Existing open Python 2 PRs can still be merged if they seem useful and low risk.
  4. We can remove some Python 2 specific test cases if they are hard to maintain (e.g. require runtime access to Python 2).

cc @sobolevn who has done some recent work on Python 2 features.

@JukkaL JukkaL added the meta Issues tracking a broad area of work label Feb 22, 2022
@97littleleaf11 97littleleaf11 pinned this issue Feb 22, 2022
@hauntsaninja
Copy link
Collaborator

#12202 was a pretty significant Python 2 regression and we've only gotten the one report from it :-)

@JelleZijlstra
Copy link
Member

Worth noting that mypy appears to be the last type checker to still support Python 2. Pyre and pyright never supported it; pytype and pyanalyze dropped support last year. We also stopped updating the typing backport for Python 2. Once mypy drops Python 2 support, we should also remove the Python 2 stubs from typeshed.

@hauntsaninja
Copy link
Collaborator

Is Python 2 support still important for Dropbox?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 23, 2022

Is Python 2 support still important for Dropbox?

No.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 23, 2022

Worth noting that mypy appears to be the last type checker to still support Python 2.

I think that PyCharm still supports Python 2.

There are also quite a few downloads of the typing backport for Python 2 (on the order of 150k-200k downloads per day): https://pypistats.org/packages/typing

@JukkaL
Copy link
Collaborator Author

JukkaL commented Mar 31, 2022

I closed existing Python 2 specific issues (thanks @AlexWaygood for tagging them!). We don't need to keep open any new issues that only affect Python 2, unless it is a regression in a recent mypy release.

@ethanhs
Copy link
Collaborator

ethanhs commented May 19, 2022

I found out that there is a regression in typeshed that makes type checking Python 2 code impossible in 0.950 python/typeshed#7367 (comment)

It seems that no one else has Python 2 installed, so all the relevant tests were getting skipped, including in CI.

Since we effectively haven't been testing Python 2 support, I think we should just drop support in the next release. I don't think there is much to be gained from fixing this issue, and I don't really want to ask anyone who maintains typeshed to fix it :)

Perhaps we can post on the blog that we are considering dropping support for Python 2 in 0.960 in a blog post prior to the release so that if anyone has a problem with it they can open an issue (or better yet comment on this one).

Also to clarify: I am not worried about this specific issue, more that we aren't really checking Python 2 in CI anymore, so I think we shouldn't claim to support it.

@JukkaL
Copy link
Collaborator Author

JukkaL commented May 19, 2022

Does the Python 2 issue cause serious problems outside tests? I was able to type check simple Python 2 code examples without problems, at least.

@ethanhs
Copy link
Collaborator

ethanhs commented May 19, 2022

I think anything using set, mutable set or anything that inherits from AbstractSet will probably be broken.

@JukkaL
Copy link
Collaborator Author

JukkaL commented May 20, 2022

The Python 3 stubs apparently generate similar errors, but they are ignored. Example:

class set(MutableSet[_T], Generic[_T]):
    ...
    def __ior__(self: Self, __s: AbstractSet[_T]) -> Self: ...  # type: ignore[override,misc]

Since we don't normally report errors from typeshed stubs, the issue seems benign. I'll prepare a typeshed PR that ignores the errors in the Python 2 stubs as well.

@JukkaL
Copy link
Collaborator Author

JukkaL commented May 20, 2022

Suggested fix to the Python 2 issues: python/typeshed#7894

@hauntsaninja
Copy link
Collaborator

It is now second half of 2022 — can we drop support? I'm sure people who are happy with Python 2 will also be happy pinning to an older version of mypy; we can even have --python2 automatically suggest that.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jun 15, 2022

The second half of 2022 starts on July 1st, so we are almost -- but not quite -- there.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jul 11, 2022

It's now the second half of 2022, so we can finally drop Python 2 support.

List of steps (this is probably incomplete):

  • Wait until typeshed removes Python 2 stubs.
  • Remove test cases specific to Python 2.
  • Make the -2, --py2 and --python version 2.7 options print an error and suggest using an older version of mypy.
  • Sync typeshed (removes Python 2 stubs).
  • Remove Python 2 specific things in the documentation.
  • Remove Python 2 parser (mypy/fastparse2.py).
  • Remove support for pip install mypy[python2] and the optional typed-ast dependency on recent Python versions.
  • Remove Python 2 specific type checker logic.

@sobolevn
Copy link
Member

I also propose to drop six / similar libraries support, since python2 is no longer supported.

#13567

@ethanhs
Copy link
Collaborator

ethanhs commented Aug 31, 2022

Won't some Python 3 code that was ported from Python 2 still have six usage in it?

@ilevkivskyi
Copy link
Member

Yeah, I can add +1 to @ethanhs comment. There is some code that runs on Python 3, but is still being cleaned up from all the six things.

@JukkaL JukkaL changed the title Python 2 feature freeze Python 2 feature freeze (and removal of support) Sep 1, 2022
@SamB
Copy link

SamB commented Sep 28, 2022

I think you need to add a new version to the readthedocs config now that is also pinned to an older version so that people can still easily get the needed docs when they're dealing with legacy Python 2 stuff?

@SamB
Copy link

SamB commented Sep 28, 2022

(It might also be worth adding something somewhere to the documentation about the removed support?)

@hauntsaninja
Copy link
Collaborator

Closing, since this is done.

Use of the Python 2 options with new mypy has a nice error message which should be enough documentation.

Not planning on more readthedocs config for this. Python 2 is dead. I assume if people still have Python 2 codebases they have bigger problems than tweaking their mypy config. And git is always forever. If you feel strongly, open another issue and see if it gets upvotes.

@schlamar
Copy link

@hauntsaninja It would be really great if you could re upload the last documentation with Python 2 support on readthedocs as an additional version. Right now, it has become nearly impossible to find online useful information regarding type hints for Python 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Issues tracking a broad area of work topic-python2 issues only applicable to Python 2
Projects
None yet
Development

No branches or pull requests

9 participants