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

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.20261008
File Size Uploaded
pycaw_stubs-20260927.20261008.tar.gz 9.4 kB Details

Built distribution (wheel)

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

Total release size: 24.2 kB

Release files / pycaw_stubs-20260927.20261008.tar.gz

Download URL pycaw_stubs-20260927.20261008.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
754d996a087d3c0fa97ff293499ecb4b1410ce7ec547fad88b8e75ebcc99466f
BLAKE2b-256 checksum
How to use checksums
240bb55500c1962df173fb44391a5cd78eb3b899cabb1d64ad2ae3cf2d71a93a
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.20261008-py3-none-any.whl

Download URL pycaw_stubs-20260927.20261008-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b902968e606fa57f994102038e98732d526c475dec46e5f9c17d94d822732433
BLAKE2b-256 checksum
How to use checksums
4d7b79c35ee51fc190415d031dd88734fa497c92ec7821cd9a74768aafba398c
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.20261008 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