Skip to content

PEP 561 stub packages should take precedence over bundled .pyi stubs #18997

Closed
@jorenham

Description

@jorenham

NumPy relies on bundled .pyi stubs for static typing. They live side-by-side with the .py (if they exist). See e.g. https://github.com/numpy/numpy/tree/main/numpy.

NumType is a static-typing project that we are developing. It comes with (different) numpy-stubs stubs-only package for numpy. It is a backwards-incompatible rework of the stubs that are bundled with numpy containing experimental new features, and will therefore be opt-in (once released).

If both numpy and NumType's numpy-stubs are installed, PEP 561 states that numpy-stubs should take precedence over the ones from numpy. Mypy does this the other way around, effectively ignoring the new numpy-stubs.

This effectively means that we currently cannot support mypy. So I consider this to be a big problem.

The only workaround I was able find is to delete all .pyi in the local numpy installation directory. But this isn't something we can realistically ask of our users.
So if any other workarounds come to mind, please let me know :)

Repro-repo with additional details

https://github.com/jorenham/mypy-pep561-numpy-issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions