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-105578: Raise `DeprecationWarning` on `typing.AnyStr` usage by sobolevn · Pull Request #150190 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented May 21, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Discourage and deprecate typing.AnyStr #105578

Sorry, something went wrong.

Uh oh!

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

All reactions
@sobolevn
sobolevn requested review from AA-Turner, AlexWaygood and JelleZijlstra as code owners May 21, 2026 13:25
@bedevere-app bedevere-app Bot mentioned this pull request May 21, 2026
Discourage and deprecate typing.AnyStr #105578
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label May 21, 2026
@sobolevn
pythongh-105578: Raise DeprecationWarning on typing.AnyStr usage
9d9d3df
@sobolevn
sobolevn force-pushed the issue-105578 branch from 9ac3de0 to 9d9d3df Compare May 21, 2026 13:27
@read-the-docs-community

read-the-docs-community Bot commented May 21, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35682839 | 📁 Comparing e136d10 against main (c35b0f2)

  🔍 Preview build  

463 files changed · + 15 added · ± 447 modified · - 1 deleted

+ Added

  • builtins/constants.html
  • builtins/exceptions.html
  • builtins/functions.html
  • builtins/index.html
  • builtins/stdtypes.html
  • builtins/threadsafety.html
  • builtins/time-complexity.html
  • c-api/pyexpat.html
  • howto/abi3t-migration.html
  • library/asyncio-threading.html
  • and 5 more...

± Modified

  • bugs.html
  • glossary.html
  • index.html
  • license.html
  • py-modindex.html
  • _static/tachyon-example-heatmap.html
  • c-api/arg.html
  • c-api/bool.html
  • c-api/buffer.html
  • c-api/bytearray.html
  • and 437 more...

- Deleted

  • library/asyncio-policy.html
All reactions

Sorry, something went wrong.

Uh oh!

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

AlexWaygood
AlexWaygood reviewed May 21, 2026
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.

Thanks! Wow, that came around quickly.

I had to think this through again, but I think this is correct: this is a deprecation for Python 3.16, which will become stable in autumn 2027, around the same time that Python 3.11 goes end-of-life. That means that the deprecation warnings will start to be emitted at basically the same time that the lowest non-EOL Python version is Python 3.12 -- and Python 3.12 is the first version in which users can use PEP-695 syntax

Sorry, something went wrong.

Uh oh!

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

sobolevn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/library/typing.rst Resolved

Uh oh!

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

Comment thread Lib/typing.py Resolved

Uh oh!

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

@sobolevn
Address review
1f3c6b4
JelleZijlstra
JelleZijlstra reviewed May 21, 2026
View reviewed changes
Comment thread Lib/typing.py Resolved

Uh oh!

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

@AlexWaygood

AlexWaygood commented May 21, 2026

Copy link
Copy Markdown
Member

the test failures from the deprecation warnings in setuptools in https://github.com/python/cpython/actions/runs/26230364757/job/77188896358?pr=150190 do seem a bit concerning. Do we need to update setuptools before landing this?

Avasam reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@sobolevn sobolevn mentioned this pull request May 21, 2026
Remove typing.AnyStr usage pypa/setuptools#5232
Merged
2 tasks
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 19, 2026
@sobolevn
Merge branch 'main' into issue-105578
887a5e2
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 28, 2026
@sobolevn

sobolevn commented Oct 28, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Setuptools is updated, new version is released. I've fixed all merge conflicts.

All reactions

Sorry, something went wrong.

Uh oh!

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

sobolevn
sobolevn commented Oct 28, 2026
View reviewed changes
Comment thread Lib/typing.py Resolved

Uh oh!

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

Comment thread Doc/deprecations/pending-removal-in-3.18.rst Resolved

Uh oh!

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

@sobolevn
Apply suggestions from code review
e5248b6
@sobolevn sobolevn removed the stale Stale PR or inactive for long period of time. label Oct 28, 2026
StanFromIreland
StanFromIreland reviewed Oct 28, 2026
View reviewed changes
Comment thread Doc/deprecations/pending-removal-in-3.18.rst Resolved

Uh oh!

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

StanFromIreland
StanFromIreland reviewed Oct 28, 2026
View reviewed changes
Comment thread Lib/test/test_typing.py Resolved

Uh oh!

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

@sobolevn
Fix lazy imports CI
2eb9c1b
@sobolevn

sobolevn commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

We can address the setuptools.whl tests failures in two ways:

  1. We can update the bundled .whl to a newer version
  2. Or we can add warnings ignore guards

I think that both have their downsides, but I would probably go with 1 :)

All reactions

Sorry, something went wrong.

Uh oh!

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

hugovk
hugovk reviewed Oct 28, 2026
View reviewed changes
Comment thread Doc/deprecations/pending-removal-in-3.21.rst Resolved

Uh oh!

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

Comment thread Lib/typing.py Resolved

Uh oh!

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

Comment thread Lib/typing.py Resolved

Uh oh!

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

Comment thread Lib/typing.py Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Library/2026-05-21-16-15-01.gh-issue-105578.oq-0pg.rst Resolved

Uh oh!

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

sobolevn and others added 2 commits October 28, 2026 14:51
@sobolevn @hugovk
Apply suggestions from code review
3e321d4
Co-authored-by: Hugo van Kemenade <[email protected]>
@sobolevn
Fix removal date
adfaf3d
@sobolevn sobolevn mentioned this pull request Oct 28, 2026
Update bundled test setuptools.whl file #160824
Closed
@sobolevn

sobolevn commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

I created #160824 to discuss the setuptools update.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sobolevn
Merge branch 'main' into issue-105578
9b9c5ca
@sobolevn

sobolevn commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

I fixed setuptools, updated the bundled wheel file, now tests should pass (finally 🎉)!

Please, take another look :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@sobolevn
sobolevn requested review from JelleZijlstra and hugovk November 5, 2026 14:12
JelleZijlstra
JelleZijlstra approved these changes Nov 5, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Nov 5, 2026
hugovk
hugovk approved these changes Nov 5, 2026
View reviewed changes
Comment thread Doc/whatsnew/3.16.rst Resolved

Uh oh!

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

@sobolevn
Fix whatsnew entry
e136d10
@sobolevn
sobolevn enabled auto-merge (squash) November 5, 2026 21:34
@sobolevn

sobolevn commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Thanks a lot, everyone! 🎉

All reactions

Sorry, something went wrong.

Uh oh!

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

@sobolevn
sobolevn merged commit d746542 into python:main Nov 5, 2026
53 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 5, 2026
@hugovk

hugovk commented Nov 6, 2026

Copy link
Copy Markdown
Member

Looks like this has caused buildbot refleak failures:

https://buildbot.python.org/release-status

For example:

  • Before: https://buildbot.python.org/#/builders/853/builds/4488
  • After: https://buildbot.python.org/#/builders/853/builds/4489

The other test that does import_helper.import_fresh_module('typing') has self.addCleanup(atexit.unregister, typing._clear_caches).

cpython/Lib/test/test_typing.py

Lines 6570 to 6585 in 3feccd1

def test_collect_parameters(self):
typing = import_helper.import_fresh_module("typing")
# Importing typing registers an internal function named _clear_caches
# with atexit. The throwaway module created here installs its own
# handler, which holds the module alive and keeps references until
# interpreter shutdown even after the test finishes. Each repetition
# of this test under -R would therefore leak another module copy. To
# avoid this, we unregister the handler once the test is done.
self.addCleanup(atexit.unregister, typing._clear_caches)
with self.assertWarnsRegex(
DeprecationWarning,
"The private _collect_parameters function is deprecated"
) as cm:
typing._collect_parameters
self.assertEqual(cm.filename, __file__)

Do we need similar in test_any_str_deprecated?

All reactions

Sorry, something went wrong.

Uh oh!

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

@sobolevn

sobolevn commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Oups, sorry for that! Fixing :)

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

This was referenced Nov 6, 2026
test_typing leaks a reference in buildbots #161490
Closed
gh-161490: Fix leak in test_any_str_deprecated in test_typing #161491
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexWaygood AlexWaygood AlexWaygood left review comments
@StanFromIreland StanFromIreland StanFromIreland left review comments
@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@hugovk hugovk hugovk approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

type-feature A feature request or enhancement

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.

5 participants

@sobolevn @AlexWaygood @hugovk @JelleZijlstra @StanFromIreland
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.