GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-92871: Remove typing.{io,re} namespaces by srittau · Pull Request #92873 · python/cpython

Conversation

@srittau

@srittau srittau commented May 17, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Remove typing.io and typing.re #92871

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@srittau
Remove typing.{io,re} namespaces
149e383
Closes: python#92871
@srittau
srittau requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners May 17, 2022 08:56
@bedevere-bot bedevere-bot added the awaiting review label May 17, 2022
@srittau srittau mentioned this pull request May 17, 2022
Remove typing.io and typing.re #92871
Closed
@AlexWaygood AlexWaygood added topic-typing 3.12 only security fixes labels May 17, 2022
@Fidget-Spinner

Fidget-Spinner commented May 17, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented May 17, 2022

Copy link
Copy Markdown
Member

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

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum
gvanrossum reviewed May 17, 2022
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_typing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2022-05-17-10-46-44.gh-issue-92871.GVogrT.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

srittau added 2 commits May 17, 2022 17:22
@srittau
Remove unnecessary test
fbd91c0
@srittau
Fix grammar
4bbea03
@srittau

srittau commented May 17, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood
AlexWaygood reviewed May 17, 2022
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/typing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@srittau @AlexWaygood
Update comment
05b53ca
Co-authored-by: Alex Waygood <[email protected]>
@srittau

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 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood
AlexWaygood approved these changes May 17, 2022
View reviewed changes

@AlexWaygood AlexWaygood left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels May 17, 2022
@srittau

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented May 17, 2022

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 17, 2022

Copy link
Copy Markdown
Member

I wrote a different script: https://github.com/faster-cpython/tools/blob/main/scripts/download_packages.py

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 17, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra
JelleZijlstra reviewed May 18, 2022
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@srittau srittau mentioned this pull request May 18, 2022
Replace typing.re import wemake-services/wemake-python-styleguide#2414
Merged
1 of 4 tasks
@srittau

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):

  • Replace typing.re import ktbyers/netmiko#2788
  • Replace typing.re import wemake-services/wemake-python-styleguide#2414

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

srittau commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

typing.io:

  • [Bug] Obsolete typing.io import hydra-ecosystem/hydra#2218
  • Remove obsolete typing.io import cognitedata/cognite-sdk-python#922
  • Vendored importlib_resources uses obsolete typing.io import pypa/pipenv#5106
  • Generated files use obsolete typing.io import hydra-ecosystem/omegaconf#936
  • stix-patterns conditionally imports typing.io only on Python < 3.6.
  • Same for antlr4-python3-runtime
  • amazon-dax-client doesn't seem to have a public bug tracker, so I consider this Amazon's problem

Ignoring a Python 2 package and the typing backport.

hauntsaninja reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau @JelleZijlstra
Self-promotion 💪
387712e
Co-authored-by: Jelle Zijlstra <[email protected]>
hauntsaninja
hauntsaninja approved these changes Oct 10, 2022
View reviewed changes

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hooray! Shall we merge?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra

JelleZijlstra commented Oct 10, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@srittau

srittau commented Oct 10, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@warsaw

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja hauntsaninja removed the 3.12 only security fixes label Oct 28, 2022
@srittau srittau mentioned this pull request Nov 1, 2022
gh-92871: Postpone the removal of typing.{io,re} to 3.13 #98958
Merged
@hauntsaninja
hauntsaninja marked this pull request as draft December 22, 2022 22:23
@srittau
Merge branch 'main' into rm-typing-submodules
6c75b1a
@srittau

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented May 23, 2023

Copy link
Copy Markdown
Member

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

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra JelleZijlstra self-assigned this May 23, 2023
methane
methane reviewed May 23, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@srittau
Merge branch 'main' into rm-typing-submodules
6e5bc6d
Move NEWS entry from 3.12 to 3.13.
@srittau
srittau marked this pull request as ready for review May 23, 2023 10:46
@bedevere-bot bedevere-bot added awaiting review and removed awaiting core review labels May 23, 2023
@srittau

srittau commented May 23, 2023

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra
JelleZijlstra reviewed May 23, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.13.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra
JelleZijlstra reviewed May 23, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2022-05-17-10-46-44.gh-issue-92871.GVogrT.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra
Apply suggestions from code review
e3f97d4
JelleZijlstra
JelleZijlstra approved these changes May 23, 2023
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks @srittau!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels May 23, 2023
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) May 23, 2023 13:13
AlexWaygood
AlexWaygood approved these changes May 23, 2023
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM too :) thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra
JelleZijlstra merged commit abdda5b into python:main May 23, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 23, 2023
@srittau
srittau deleted the rm-typing-submodules branch May 23, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane left review comments
@gvanrossum gvanrossum gvanrossum left review comments
@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@hauntsaninja hauntsaninja hauntsaninja approved these changes
@AlexWaygood AlexWaygood AlexWaygood approved these changes
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@JelleZijlstra JelleZijlstra

Labels

topic-typing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@srittau @Fidget-Spinner @JelleZijlstra @gvanrossum @vstinner @warsaw @methane @hauntsaninja @AlexWaygood @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.