Skip to content

Update stdlib for Python 3.15#15714

Draft
JelleZijlstra wants to merge 30 commits intopython:mainfrom
JelleZijlstra:python315
Draft

Update stdlib for Python 3.15#15714
JelleZijlstra wants to merge 30 commits intopython:mainfrom
JelleZijlstra:python315

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra commented May 8, 2026

Part of #15709.

I pointed Codex at the What's New for 3.15 and told it to apply every change relevant to typeshed, then told it to get stubtest running on 3.15 (which found python/cpython#149504) and fix the remaining issues. I also reviewed manually and made a few adjustments (including noticing python/cpython#149534).

I'm not sure about the way it approached urllib.parse and I might redo that, but mostly this appears to be correct.

I also had it make a list of all the changes with relevant PRs and links to the CPython code:

# Conflicts:
#	stdlib/_interpqueues.pyi
#	stdlib/ast.pyi
#	stdlib/base64.pyi
#	stdlib/collections/__init__.pyi
#	stdlib/glob.pyi
#	stdlib/importlib/metadata/__init__.pyi
#	stdlib/pyexpat/__init__.pyi
#	stdlib/sys/__init__.pyi
#	stdlib/threading.pyi
#	stdlib/types.pyi
#	stdlib/typing.pyi
#	stdlib/unicodedata.pyi
#	stdlib/unittest/_log.pyi
#	stdlib/unittest/case.pyi
#	stdlib/wave.pyi
#	stdlib/zipimport.pyi
@github-actions

This comment has been minimized.

@srittau
Copy link
Copy Markdown
Collaborator

srittau commented May 8, 2026

I would like to get the testing infrastructure for 3.15 up before adding 3.15 branches. It also doesn't fill me with confidence that we already have stubtest errors without even testing 3.15.

@srittau
Copy link
Copy Markdown
Collaborator

srittau commented May 8, 2026

Here's my suggestion on how to move forward:

  1. Get the testing infrastructure in place. We'll need to add many stubtest allow entries as a "to do list" to the 3.15 allow lists. (Like we had in the past.)
  2. Split this PR into multiple PRs with a size that's easily reviewable.
  3. Fix remaining issues per PR, but move "harder" fixes to separate PRs if necessary.
  4. Review each PR manually for plausibility and style. When looking at the existing PR, it's clear to me that on the one hand the LLM managed to do a lot of the "grunt work" and provide a good baseline, but on the other hand delivered results that are not suitable for unsupervised inclusion in typeshed.

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this work! I agree with @srittau that it is rather hard to review 1600+ lines of changes accross different modules :(

Comment thread stdlib/collections/__init__.pyi Outdated
from typing_extensions import Self, disjoint_base

if sys.version_info >= (3, 15):
from builtins import frozendict as frozendict
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.

Do we really want to re-export frozendict from collections?

Comment thread stdlib/sys/__init__.pyi Outdated
if sys.platform != "win32":
abiflags: str
if sys.version_info >= (3, 15):
abi_info: SimpleNamespace
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.

It would be nice to type the fields as well:

>>> import sys
>>> sys.abi_info
namespace(pointer_bits=64, free_threaded=False, debug=True, byteorder='little')

@mbyrnepr2
Copy link
Copy Markdown

Hi! There's one new addition in 3.15 which I notice is missing from the release notes and the current PR:
python/cpython#140951
https://docs.python.org/3.15/library/wave.html#wave.open.

I guess if the What's New is up to date there shouldn't be a problem for the AI but maybe there are other changes also missing?

@JelleZijlstra
Copy link
Copy Markdown
Member Author

wave.open: Yes, I had it look only at the What's New. I think we're liable to miss such changes to only allowed parameter types, because there's no automatic way to check them; I wouldn't be surprised if we similarly missed some changes for earlier versions. Maybe I'll try making an AI look at the whole diff between 3.14 and 3.15 and flag things that were missed.

Point taken on getting CI set up first, I'll do that.

The stubtest failures seem to be mostly from changes that were made unconditionally that should have been made conditional on version.

@JelleZijlstra JelleZijlstra marked this pull request as draft May 8, 2026 16:11
@JelleZijlstra
Copy link
Copy Markdown
Member Author

My plan now:

  • Add 3.15 CI (Add Python 3.15 test infrastructure #15718)
  • Make Codex fix all CI issues on this PR to have a clean slate (in progress)
  • Extract separate PRs for smaller changes (probably <5 modules at a time); start them as draft and request review when I feel they're ready.

@srittau
Copy link
Copy Markdown
Collaborator

srittau commented May 8, 2026

Extract separate PRs for smaller changes (probably <5 modules at a time); start them as draft and request review when I feel they're ready.

I'll try to prioritize reviewing. If it's just small, straight-forward changes, I'm fine with larger PRs. It's more about the amount if lines and the complexity than the amount of modules.

Comment thread stdlib/profiling/sampling.pyi Outdated

class Collector(ABC):
def collect(self, stack_frames, timestamps_us=None) -> None: ...
def collect(self, stack_frames: Any, timestamps_us: Any | None = None) -> None: ...
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

these should just be left unannotated I think (same for a bunch of others in this file)

@github-actions

This comment has been minimized.

# Conflicts:
#	stdlib/@tests/stubtest_allowlists/darwin-py315.txt
#	stdlib/@tests/stubtest_allowlists/linux-py315.txt
#	stdlib/@tests/stubtest_allowlists/py315.txt
#	stdlib/@tests/stubtest_allowlists/win32-py315.txt
#	stdlib/_collections_abc.pyi
#	stdlib/_socket.pyi
#	stdlib/_ssl.pyi
#	stdlib/binascii.pyi
#	stdlib/builtins.pyi
#	stdlib/calendar.pyi
#	stdlib/collections/__init__.pyi
#	stdlib/datetime.pyi
#	stdlib/difflib.pyi
#	stdlib/hashlib.pyi
#	stdlib/mmap.pyi
#	stdlib/platform.pyi
#	stdlib/re.pyi
#	stdlib/resource.pyi
#	stdlib/socket.pyi
#	stdlib/sqlite3/__init__.pyi
#	stdlib/typing.pyi
#	stdlib/unittest/_log.pyi
#	stdlib/wave.pyi

if sys.version_info >= (3, 15):
from builtins import frozendict
from builtins import frozendict as _frozendict
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

change in this file is just busywork now, I'll make sure not to put it in any split-off PRs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants