Skip to content

Commit cd73c4e

Browse files
committed
Add basic scaffolding for distributing the package
It doesn't appear that the released mypy supports _stub packages right now, so for now we have to add to MYPYPATH manually. Something else to consider is how to sync versions with numpy, but we can deal with that later, if we start our numbers low enough. This adds a very small number of stubs just to verify that installation maybe works. Fixes numpy#2
1 parent 88818fe commit cd73c4e

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

numpy/__init__.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# very simple, just enough to start running tests
2+
3+
class ndarray: pass
4+
5+
class dtype: pass
6+
7+
def array(
8+
object : object,
9+
dtype : dtype = ...,
10+
copy : bool = ...,
11+
subok : bool = ...,
12+
ndmin : int = ...) -> ndarray: ...

numpy/py.typed

Whitespace-only changes.

setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='numpy_stubs',
5+
maintainer="NumPy Developers",
6+
maintainer_email="numpy-discussion@python.org",
7+
description="PEP 561 type stubs for numpy",
8+
url="http://www.numpy.org",
9+
license='BSD',
10+
version="0.0.1",
11+
packages=find_packages(),
12+
13+
# PEP 561 requires these
14+
install_requires=['numpy~=1.13.0'],
15+
package_data={
16+
'numpy': 'py.typed'
17+
},
18+
)

tests/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Testing
2+
=======
3+
4+
To run these tests:
5+
6+
export MYPYPATH='..'
7+
mypy test_simple.py
8+
9+
In future, this should change to use the test framework used by mypy.

tests/test_simple.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import numpy as np
2+
3+
def foo(a : np.ndarray): pass
4+
5+
foo(np.array(1))

0 commit comments

Comments
 (0)