FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-92871: Remove typing.{io,re} namespaces by srittau · Pull Request #92873 · python/cpython · GitHub

/ cpython Public

gh-92871: Remove typing.{io,re} namespaces - #92873

Merged
JelleZijlstra merged 8 commits into
python:mainfrom
srittau:rm-typing-submodules
May 23, 2023
Merged

gh-92871: Remove typing.{io,re} namespaces#92873
JelleZijlstra merged 8 commits into
python:mainfrom
srittau:rm-typing-submodules

Conversation

srittau commented May 17, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

LGTM and I'm also +1 for this, but I'll wait to see what the rest have to say.

Copy link
Copy Markdown
Member

Thanks, could you check whether there's any usage of these remaining in the wild? (cf. #92547 (comment))

srittau commented May 17, 2022

Copy link
Copy Markdown
Contributor Author

Thanks, could you check whether there's any usage of these remaining in the wild? (cf. #92547 (comment))

Is there an easy way to do this? From what I understand, the scripts need a local copy of PyPI.

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good riddance. Two tiny nits. When can we start deprecating typing.Pattern/Match and the io classes in typing?

Comment thread Lib/test/test_typing.py Outdated

srittau commented May 17, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

When can we start deprecating typing.Pattern/Match and the io classes in typing?

I'm usually in the "sooner better than later" camp, but for now I wouldn't recommend to more than soft-deprecate those, until Python 3.8 goes end of life. 3.9 introduced the generics in the stdlib, so to write code compatible with 3.8 and 3.9+, you'd need to use a conditional import otherwise.

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just one suggestion about a comment wording.

I also agree with @JelleZijlstra that we should check how much these are used in the wild before removing them, especially since we've never emitted DeprecationWarnings for these. Some people use the objects in the typing module for purposes other than static typing, so there might still be some people using these namespaces even though they've never been supported by type-checkers.

Comment thread Lib/typing.py Outdated
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

srittau commented May 17, 2022

Copy link
Copy Markdown
Contributor Author

I also agree with @JelleZijlstra that we should check how much these are used in the wild before removing them, especially since we've never emitted DeprecationWarnings for these.

We do emit DeprecationWarnings, starting with Python 3.11.

AlexWaygood left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I also agree with @JelleZijlstra that we should check how much these are used in the wild before removing them, especially since we've never emitted DeprecationWarnings for these.

We do emit DeprecationWarnings, starting with Python 3.11.

🤦‍♂️

I'd still like to double-check that there aren't too many uses of these in the wild, but providing there aren't, looks good!

srittau commented May 17, 2022

Copy link
Copy Markdown
Contributor Author

I'd still like to double-check that there aren't too many uses of these in the wild, but providing there aren't, looks good!

Sounds like a good idea, if someone can do it and give me guidance on how to do it.

Copy link
Copy Markdown
Member

I think @vstinner has a script to get the top 5k, but I can't find it documented.

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

I think @vstinner has a script to get the top 5k, but I can't find it documented.

I just documented it in my doc: https://pythondev.readthedocs.io/test_next_python.html#top-5000-pypi-packages

I wrote these scripts for my own needs. It's based the script that @methane wrote to see how the PyUnicode C API was used.

For example, search_pypi_top.py ignores Cython files (use --cython option to not exclude them: see --help). Previously, I used rg for code serach, but it doesn't give the filename inside an archive and it doesn't show the matching line. Also, I needed something more specific to Python.

Comment thread Doc/whatsnew/3.12.rst Outdated

srittau commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

Thanks, @vstinner and @gvanrossum, that was very helpful! I did run Victor's script for the top 5000 packages, and here are the results:

typing.re: Two affected projects (ignoring the typing backport):

A quick count show 7 affected projects for typing.io. I will send PRs later.

srittau commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

typing.io:

Ignoring a Python 2 package and the typing backport.

srittau commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

This makes for a total of 7 out of 5000 affected projects or 0.14%.

srittau commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

@vstinner You mean beyond the PRs and issues linked above? typing.re and typing.io hasn't been necessary since at least Python 3.6, if ever. I don't think typeshed ever supported those namespaces.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hooray! Shall we merge?

Copy link
Copy Markdown
Member

As far as I can tell we emit a DeprecationWarning only on 3.11, not 3.10. Therefore, following https://peps.python.org/pep-0387/#making-incompatible-changes we should wait until 3.13, not 3.12, to remove these.

srittau commented Oct 10, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

In that case we need to retroactively update the documentation, which says that they will be removed in Python 3.12.

warsaw commented Oct 10, 2022

Copy link
Copy Markdown
Member

I just documented it in my doc: https://pythondev.readthedocs.io/test_next_python.html#top-5000-pypi-packages

I wonder if there's any way to automate this, say, given some special tag for deprecation removals?

hauntsaninja removed the 3.12 only security fixes label Oct 28, 2022
hauntsaninja marked this pull request as draft December 22, 2022 22:23

srittau commented Jan 24, 2023

Copy link
Copy Markdown
Contributor Author

The "What's new" comment needs to be moved to the 3.13 document when it becomes available.

Copy link
Copy Markdown
Member

We're now ready to remove this in 3.13. @srittau do you want to update the PR?

JelleZijlstra self-assigned this May 23, 2023
Comment thread Doc/whatsnew/3.12.rst Outdated
Move NEWS entry from 3.12 to 3.13.
srittau marked this pull request as ready for review May 23, 2023 10:46

srittau commented May 23, 2023

Copy link
Copy Markdown
Contributor Author

Done, merged main and moved the NEWS entry in the process.

Comment thread Doc/whatsnew/3.13.rst Outdated

JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @srittau!

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM too :) thanks!

JelleZijlstra merged commit abdda5b into python:main May 23, 2023
srittau deleted the rm-typing-submodules branch May 23, 2023 15:07
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants


Back | FazBrowse Home | New Git URL