Skip to main content

pycaw-stubs

Type stubs for pycaw (Python Core Audio Windows Library), so that pyright, mypy, and other type checkers understand its API instead of reporting errors such as:

error: "GetMasterVolumeLevelScalar" is not a known attribute of ...
error: "EndpointVolume" is not a known attribute of "None" (reportOptionalMemberAccess)

pycaw creates its COM interface methods at runtime, so type checkers cannot see them in its source code. These stubs declare those methods, along with the AudioUtilities, AudioDevice, AudioSession, callback and magic APIs.

This is an independent project, not part of pycaw.

Installation

pip install pycaw-stubs

Type checkers pick the stubs up automatically; no configuration is needed.

from pycaw.pycaw import AudioUtilities

volume = AudioUtilities.GetSpeakers().EndpointVolume
level = volume.GetMasterVolumeLevelScalar()  # float
low, high, step = volume.GetVolumeRange()  # tuple[float, float, float]
volume.SetMasterVolumeLevelScalar(0.5, None)

for session in AudioUtilities.GetAllSessions():
    if session.Process is not None:  # psutil.Process | None
        print(session.Process.name(), session.SimpleAudioVolume.GetMasterVolume())

The stubs work with Python 3.10 and later, in both standard and strict mode of pyright and mypy.

Versions

The version number is <pycaw version>.<stub release date>. For example, pycaw-stubs 20260927.20261007 describes pycaw 20260927. Install the stubs whose first part matches your pycaw version where possible.

Limitations

comtypes, which pycaw is built on, has no type information. Its types (IUnknown, GUID, COMObject) are therefore treated as Any:

  • Methods that pycaw declares, such as GetMasterVolumeLevelScalar(), are fully typed.

  • Methods that come from comtypes, such as QueryInterface(), AddRef() and Release(), are accepted but return Any. With mypy --strict, returning such a value directly from a typed function reports no-any-return; assign it to an annotated variable first:

    volume: IAudioEndpointVolume = interface.QueryInterface(IAudioEndpointVolume)
    

    The typed helpers, such as AudioUtilities.GetSpeakers().EndpointVolume, avoid this.

  • If your own code imports comtypes, pyright's strict mode reports Stub file not found for "comtypes". That message is about comtypes, not these stubs.

Contributing

Bug reports and fixes are welcome at github.com/amnweb/pycaw-stubs. See CONTRIBUTING.md for how to run the checks and update the stubs.

License

MIT, see LICENSE. pycaw itself is MIT-licensed by Andre Miras.

Metadata

Release files for pycaw-stubs 20260927.20261007

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycaw-stubs 20260927.20261007
File Size Uploaded
pycaw_stubs-20260927.20261007.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycaw-stubs 20260927.20261007
File Interpreter ABI Platform
pycaw_stubs-20260927.20261007-py3-none-any.whl Python 3 none any Details

Total release size: 24.1 kB

Release files / pycaw_stubs-20260927.20261007.tar.gz

Download URL pycaw_stubs-20260927.20261007.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a835c6621e4cbf64b6e5981603eb811d63d40a4d774b520afbbf8e148e5a2424
BLAKE2b-256 checksum
How to use checksums
b6bbf3ae69190a27ea1b66ff04f633aed5dd0ea369419a3cc4935b0ec6d6445e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / pycaw_stubs-20260927.20261007-py3-none-any.whl

Download URL pycaw_stubs-20260927.20261007-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebc0aa202d20638d1dbcc64f1a70f55b3d13dd55b1b8833860312e05beecddc9
BLAKE2b-256 checksum
How to use checksums
e1d068566cd89b9c43e81ae5b3996263238b72fdc2c9ce8ca83093c93a528cc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

20260927.20261007 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page