You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PEP 561 stub packages should take precedence over bundled .pyi stubs #18997
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 :)
Activity
JelleZijlstra commentedon Apr 29, 2025
Relevant section of the spec: https://typing.python.org/en/latest/spec/distributing.html#import-resolution-ordering
jorenham commentedon Apr 29, 2025
I'm not familiar with the mypy codebase, but maybe it's related to the order of these conditions
mypy.modulefinder.FindModuleCache._find_module?mypy/mypy/modulefinder.py
Lines 513 to 523 in 7b4f631
reproduce python#18997
Prioritize `.pyi` from `-stubs` packages over bundled `.pyi` (#19001)