Skip to content

Conversation

@hunterhogan
Copy link
Contributor

Introduce core functionality and metadata for the resampy library, including initial stubs for resampling methods and filter functions. Update metadata to specify dependencies.

See also #15338.

@github-actions

This comment has been minimized.

hunterhogan and others added 7 commits January 30, 2026 23:44
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Contributor

@donbarbos donbarbos left a comment

Choose a reason for hiding this comment

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

Thank you! I’ve found a few more points; sorry for such a fragmentary review.

@hunterhogan
Copy link
Contributor Author

Thank you! I’ve found a few more points; sorry for such a fragmentary review.

No, thank YOU! About the "fragmentary review": I certainly understand that if you were reviewing the work of a peer, they would likely prefer everything at once. But I'm not your peer, and my PR needs a lot more reviewing than a PR from an experienced programmer.

And to be frank, I'm very happy you did not put all of this in the first review. I think that would have been disheartening for me. These "fragments" are just the right size for me: I'm learning, but not overwhelmed.

Thank you very much for your patience with my inexperience and for essentially mentoring me through this process.

I'll study the comments you left and make changes.

hunterhogan and others added 5 commits January 31, 2026 21:15
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@github-actions

This comment has been minimized.

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hunterhogan
Copy link
Contributor Author

unrecognized setting "$schema".

Running: /opt/hostedtoolcache/Python/3.13.11/x64/bin/pyright --pythonplatform Windows --pythonversion 3.9
Config contains unrecognized setting "$schema".

https://github.com/python/typeshed/actions/runs/21557033413/job/62115164783?pr=15341#step:11:24

On my computer, I get the same output.

>py -m tests.runtests stubs/resampy --run-stubtest
...

Running: C:\Program Files\nodejs\npx.CMD pyright@1.1.408 stubs\resampy --pythonversion 3.9 -p pyrightconfig.stricter.json
0 errors, 0 warnings, 0 informations
Config contains unrecognized setting "$schema".
All tests.runtests Details

(.venv) C:\clones\typeshed>py -m tests.runtests stubs/resampy --run-stubtest

Running pre-commit...
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check toml...............................................................Passed
check for merge conflicts................................................Passed
mixed line ending........................................................Passed
check for case conflicts.................................................Passed
Run ruff on stubs, tests and scripts.....................................Passed
Run ruff on the test cases...........................(no files to check)Skipped
black....................................................................Passed
flake8...................................................................Passed
Check hooks apply to the repository..................(no files to check)Skipped

Running check_typeshed_structure.py...

Running Pyright (stricter configs) for Python 3.9...
11.4.2
Running: C:\Program Files\nodejs\npx.CMD pyright@1.1.408 stubs\resampy --pythonversion 3.9 -p pyrightconfig.stricter.json
0 errors, 0 warnings, 0 informations
Config contains unrecognized setting "$schema".


Running mypy for Python 3.9...
*** Testing Python 3.9 on win32
Testing third-party packages...
testing resampy (5 files)... success

--- success, 5 files checked ---

Running stubtest...
resampy... (65.07 s) success
Note: resampy is not currently tested on win32 in typeshed's CI

Regression tests: No test_cases folder for 'resampy'!


--- TEST SUMMARY: All tests passed! ---

pre-commit Success
Check structure: Success
Pyright: Success
mypy: Success
stubtest: Success
Pyright regression tests: Success
mypy regression test: Success

Is that important?

np.floating

The failures on Python 3.9 are of the following type:

error: Expected type arguments for generic class "floating"

But maybe that is because of the schema, above.

kwargs and ndarray

I wrote this stub 11 months ago, and I guess I have learned a lot more than I realized since then. I fixed kwargs: Any. We actually know exactly what the keywords and their types are. I mimicked Unpack from ast.pyi, but I'm certainly not claiming that is the "best" or the "right" way to annotate this.

I also realized that I was letting the type checker boss me around. The np.ndarray used as filters in this package are very specific: 1-axis, float64. Always. I was annotating based on what Pylance was telling me instead of using my brain to read the freaking code. Therefore, I tightened up those annotations.

"internal" functions

_resample_loop is clearly internal, so I removed it.

I think resample_f_s and resample_f_p are best categorized as internal also. I cannot imagine why I would bypass core.resample or core.resample_nu and directly call resample_f_p or resample_f_s. The two "core" functions have defensive coding and logic that I would need to duplicate. The authors didn't add either of those functions to any __all__ statement or to __init__.py, either. But that would create an empty stub file, and the idea of an intentionally empty stub file seems bizarre to me. It's probably normal, but I compulsively annotate everything.

I tried removing them and the allowlist, but the tests on my computer were unhappy.

error: resampy.interpn.resample_f_p is not present in stub
Stub: in file C:\clones\typeshed\stubs\resampy\resampy\interpn.pyi
MISSING
Runtime: at line 73
def (x, t_out, interp_win, interp_delta, num_table, scale, y)

error: resampy.interpn.resample_f_s is not present in stub
Stub: in file C:\clones\typeshed\stubs\resampy\resampy\interpn.pyi
MISSING
Runtime: at line 81
def (x, t_out, interp_win, interp_delta, num_table, scale, y)

I restored the stubtest_allowlist, and wrote a comment.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

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

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