python / python/cpython

_wave_parameters in wave.py should be public

Open
#94,991 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Make the named tuple _wave_parameters public. This nameed tuple defines the inputs to Wave_write.setparams which is a public method that users would want to call. To best create an input to setparams one would ideally first make a _wave_parameters named tuple.

This is especially true in a typed environment (see https://github.com/python/typeshed/issues/8322) but I feel it would be useful for all users of the wave module.

Pitch

Currently if one wants to call setparams in a typed setting, the only option is to use the private type:

import wave
with wave.open("test.wav", "wb") as wav_file:
    params = wave._wave_params(
        nchannels=1, sampwidth=2, framerate=16_000, nframes=0, comptype="NONE", compname="NONE",
    )
    wav_file.setparams(params)

There is no way to call setparams in a typed environment without using the wave._wave_params. If instead it was made public, all users could use the readable version of the parameters above, rather than pass in a tuple without kowing which numbers meant waht.

Previous discussion

see https://github.com/python/typeshed/issues/8322

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read Lib/wave.py around the named tuple at line 89 and the Wave_write.setparams entry point. Resolve the issue's two spellings for the tuple name, then verify that the resulting public name can be constructed by users and passed to setparams without changing its parameter meanings.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.