Skip to content

ENH: Add stub file. - #104

Open
sabonerune wants to merge 1 commit into
JeremyCCHsu:masterfrom
sabonerune:enh/type-hint
Open

ENH: Add stub file.#104
sabonerune wants to merge 1 commit into
JeremyCCHsu:masterfrom
sabonerune:enh/type-hint

Conversation

@sabonerune

Copy link
Copy Markdown
Contributor

It's almost a copy of pyworld.pyx.
Features are minimal to support older Python and Numpy.

@sabonerune sabonerune left a comment

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.

A simple type hint that's better than nothing.

Comment thread pyworld/pyworld.pyi
@@ -0,0 +1,399 @@
from typing import Optional, Tuple

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.

typing.Tuple is Deprecated.
However, removing this requires Python 3.9 (or maybe Python 3.7).
https://docs.python.org/3.13/library/typing.html#typing.Tuple

Comment thread setup.py
cmdclass={'build_ext': build_ext},
version=_VERSION,
packages=find_packages(),
package_data={"": ["py.typed", "*.pyi"]},

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.

If setuptools>=v69.0.0 this code is not needed.
https://setuptools.pypa.io/en/latest/history.html#id256

But this is only supported in Python >= 3.8.

Comment thread pyworld/pyworld.pyi

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.

Typing of ndarrays is minimal.
It would be great if we could type hint it like this:

def synthesize(
    f0: np.ndarray[tuple[int], np.dtype[np.double]],
    spectrogram: np.ndarray[tuple[int, int], np.dtype[np.double]],
    aperiodicity: np.ndarray[tuple[int, int], np.dtype[np.double]],
    fs: int,
    frame_period: float
) -> np.ndarray[tuple[int], np.dtype[np.double]]:...

But this is probably supported in numpy>=1.22 and Python>=3.9.
Python 3.10 supports Numpy 1.21.6, so it wouldn't be easy to add it without dropping one of them.

JeremyCCHsu added a commit that referenced this pull request Aug 18, 2026
- Add PEP 561 type stubs (pyworld/pyworld.pyi, pyworld/py.typed) and package_data in setup.py (#104, #105)
- Migrate from pkg_resources to importlib.metadata with fallback (#99, #103)
- Add Cython <3.1.0 constraint for Python <3.9 in pyproject.toml (#106)
- Clean requirements.txt to core dependencies and update AppVeyor demo setup (#103)
- Add sabonerune to README acknowledgements (#103)
JeremyCCHsu added a commit that referenced this pull request Aug 20, 2026
* Update lib/World submodule to latest commit, bump version to 0.3.6, fix Cython syntax

* Merge requests from open PRs (#96, #99, #103, #104, #105, #106)
- Add PEP 561 type stubs (pyworld/pyworld.pyi, pyworld/py.typed) and package_data in setup.py (#104, #105)
- Migrate from pkg_resources to importlib.metadata with fallback (#99, #103)
- Add Cython <3.1.0 constraint for Python <3.9 in pyproject.toml (#106)
- Clean requirements.txt to core dependencies and update AppVeyor demo setup (#103)
- Add sabonerune to README acknowledgements (#103)

* add 3.12 & 3.13 tests

* Pin libsndfile version for Py 3.6/3.7

* Another attempt to fix 3.6/3.7
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.

1 participant