Skip to content

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

Closed

Description

@JukkaL

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.

Activity

  1. added
    metaIssues tracking a broad area of work
    on Feb 22, 2022
  2. hauntsaninja commented on Feb 23, 2022

    @hauntsaninja
    Collaborator

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

  3. JelleZijlstra commented on Feb 23, 2022

    @JelleZijlstra
    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.

  4. hauntsaninja commented on Feb 23, 2022

    @hauntsaninja
    Collaborator

    Is Python 2 support still important for Dropbox?

  5. JukkaL commented on Feb 23, 2022

    @JukkaL
    CollaboratorAuthor

    Is Python 2 support still important for Dropbox?

    No.

  6. JukkaL commented on Feb 23, 2022

    @JukkaL
    CollaboratorAuthor

    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

  7. JukkaL commented on Mar 31, 2022

    @JukkaL
    CollaboratorAuthor

    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.

  8. emmatyping commented on May 19, 2022

    @emmatyping
    Member

    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.

  9. JukkaL commented on May 19, 2022

    @JukkaL
    CollaboratorAuthor

    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.

  10. emmatyping commented on May 19, 2022

    @emmatyping
    Member

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

  11. JukkaL commented on May 20, 2022

    @JukkaL
    CollaboratorAuthor

    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.

  12. JukkaL commented on May 20, 2022

    @JukkaL
    CollaboratorAuthor

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

  13. unpinned this issue on May 24, 2022
  14. 3 remaining items

  15. AlexWaygood commented on Jul 12, 2022

    @AlexWaygood
    Member
    • Wait until typeshed removes Python 2 stubs.

    Typeshed has now removed all its Python 2 stubs: python/typeshed#8272.

  16. sobolevn commented on Aug 31, 2022

    @sobolevn
    Member

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

    #13567

  17. emmatyping commented on Aug 31, 2022

    @emmatyping
    Member

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

  18. ilevkivskyi commented on Sep 1, 2022

    @ilevkivskyi
    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.

  19. changed the title [-]Python 2 feature freeze[/-] [+]Python 2 feature freeze (and removal of support)[/+] on Sep 1, 2022
  20. SamB commented on Sep 28, 2022

    @SamB

    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?

  21. SamB commented on Sep 28, 2022

    @SamB

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

  22. hauntsaninja commented on Oct 10, 2022

    @hauntsaninja
    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.

  23. schlamar commented on Nov 15, 2022

    @schlamar

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    metaIssues tracking a broad area of worktopic-python2issues only applicable to Python 2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions