Skip to content

Add type stubs for the wave stdlib module to align with the Python 3.15 beta changes.#15824

Merged
srittau merged 5 commits into
python:mainfrom
mbyrnepr2:wave-stubs
May 22, 2026
Merged

Add type stubs for the wave stdlib module to align with the Python 3.15 beta changes.#15824
srittau merged 5 commits into
python:mainfrom
mbyrnepr2:wave-stubs

Conversation

@mbyrnepr2
Copy link
Copy Markdown
Contributor

@mbyrnepr2 mbyrnepr2 commented May 22, 2026

Jelle mentioned in this PR comment that he may produce this change as part of an AI-related task in the future.
I thought about leaving it at that but had a rethink and decided to just take responsibility for my own cPython update.

Tested locally with:

python -m mypy --custom-typeshed-dir <my local clone of typeshed> example.py

where example.py contains:

import wave

from pathlib import Path


AUDIO_FILE = Path("sound.wav")

with wave.open(AUDIO_FILE, "rb") as wave_read:
    pass

@github-actions

This comment has been minimized.

@mbyrnepr2 mbyrnepr2 marked this pull request as ready for review May 22, 2026 09:28
Copy link
Copy Markdown
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

You could also consider inlining the type alias, as I don't think it's overly necessary here, but I leave that decision to you.

Comment thread stdlib/wave.pyi Outdated
__all__ += ["WAVE_FORMAT_PCM", "WAVE_FORMAT_IEEE_FLOAT", "WAVE_FORMAT_EXTENSIBLE"]

_File: TypeAlias = str | IO[bytes]
_File: TypeAlias = str | IO[bytes] | bytes | PathLike[Any]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
_File: TypeAlias = str | IO[bytes] | bytes | PathLike[Any]
_File: TypeAlias = StrOrBytesPath | IO[bytes]

(StrOrBytesPath needs to be imported from _typeshed.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well that looks much more readable! Let's do it.

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
srittau
srittau previously approved these changes May 22, 2026
Copy link
Copy Markdown
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau dismissed their stale review May 22, 2026 09:55

I missed something.

Copy link
Copy Markdown
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

I actually missed something really important.

Comment thread stdlib/wave.pyi Outdated
@github-actions

This comment has been minimized.

Co-authored-by: Sebastian Rittau <sebastian.rittau@zfutura.de>
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

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

@srittau srittau merged commit df45287 into python:main May 22, 2026
58 checks passed
@mbyrnepr2 mbyrnepr2 deleted the wave-stubs branch May 22, 2026 12:21
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.

2 participants