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

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

srittau
Copy link
Contributor

@srittau srittau commented May 17, 2022

No description provided.

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented May 17, 2022

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

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 17, 2022

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

@srittau
Copy link
Contributor Author

@srittau srittau commented May 17, 2022

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.

Copy link
Member

@gvanrossum gvanrossum left a comment

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

Lib/test/test_typing.py Outdated Show resolved Hide resolved
@srittau
Copy link
Contributor Author

@srittau srittau commented May 17, 2022

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.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

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.

Lib/typing.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@srittau
Copy link
Contributor Author

@srittau srittau commented May 17, 2022

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.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

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
Copy link
Contributor Author

@srittau srittau commented May 17, 2022

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.

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 17, 2022

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

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented May 17, 2022

@vstinner
Copy link
Member

@vstinner vstinner commented May 17, 2022

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.

Doc/whatsnew/3.12.rst Outdated Show resolved Hide resolved
@srittau
Copy link
Contributor Author

@srittau srittau commented May 18, 2022

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
Copy link
Contributor Author

@srittau srittau commented May 18, 2022

typing.io:

Ignoring a Python 2 package and the typing backport.

@srittau
Copy link
Contributor Author

@srittau srittau commented May 18, 2022

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

@vstinner
Copy link
Member

@vstinner vstinner commented May 18, 2022

It would be nice to notify all these affected projects that they are not compatible with the future Python 3.12 which will be released in October 2023, or even propose PRs. Simply replacing typing.re with typing drops support with Python 3.7 and older? Is there a way to remain compatible with older Python versions?

@srittau
Copy link
Contributor Author

@srittau srittau commented May 18, 2022

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

None yet

7 participants