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 }}
This repository was archived by the owner on Jun 10, 2020. It is now read-only.
MAINT: move things in numeric.pyi to the top-level __init__.pyi (#50)
In gh-38 some stubs were added for `core/numeric.py`. The problem is
that these stubs are not picked up at all, as can be tested with
```python
import numpy as np
reveal_type(np.ones_like)
```
which on master gives
```
Revealed type is 'Any'
```
The issue is that the NumPy main repo importing from numeric doesn't
automatically mean the type stubs do. We could add the relevant
imports on the stubs level too, but there is no need for the structure
of the stubs to mimic the structure of NumPy unless they are being
used to type-check NumPy itself (which we aren't doing yet), and
indeed having them mimic the internal structure just causes extra pain
of trying to keep up with internal refactors that don't affect the
public API. In fact, we already ignore NumPy's internal structure by
defining `ndarray` in the top-level `__init__.pyi`, when it is
actually exported by `numeric.py`.
So instead, just fix the issue by moving the numeric stubs into the
top level `__init__.pyi` (plus some minor bug fixes). On master the
above script now correctly gives:
```
Revealed type is 'def [_ArrayLike] (a: _ArrayLike`-1, dtype: Union[numpy.dtype, None] =, order: builtins.str =, subok: builtins.bool =, shape: Union[builtins.int, typing.Sequence[builtins.int], None] =) -> numpy.ndarray
````
0 commit comments