From dd6e3c207fdd78856bb674952e25eb59f45c2c3c Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Tue, 5 Dec 2017 22:42:17 -0800 Subject: [PATCH] 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 #2 --- numpy/__init__.pyi | 12 ++++++++++++ numpy/py.typed | 0 setup.py | 18 ++++++++++++++++++ tests/README.md | 9 +++++++++ tests/test_simple.py | 5 +++++ 5 files changed, 44 insertions(+) create mode 100644 numpy/__init__.pyi create mode 100644 numpy/py.typed create mode 100644 setup.py create mode 100644 tests/README.md create mode 100644 tests/test_simple.py diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi new file mode 100644 index 0000000..49dc2c5 --- /dev/null +++ b/numpy/__init__.pyi @@ -0,0 +1,12 @@ +# very simple, just enough to start running tests + +class ndarray: pass + +class dtype: pass + +def array( + object : object, + dtype : dtype = ..., + copy : bool = ..., + subok : bool = ..., + ndmin : int = ...) -> ndarray: ... diff --git a/numpy/py.typed b/numpy/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d3ce124 --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup, find_packages + +setup( + name='numpy_stubs', + maintainer="NumPy Developers", + maintainer_email="numpy-discussion@python.org", + description="PEP 561 type stubs for numpy", + url="http://www.numpy.org", + license='BSD', + version="0.0.1", + packages=find_packages(), + + # PEP 561 requires these + install_requires=['numpy~=1.13.0'], + package_data={ + 'numpy': 'py.typed' + }, +) diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..0067c9a --- /dev/null +++ b/tests/README.md @@ -0,0 +1,9 @@ +Testing +======= + +To run these tests: + + export MYPYPATH='..' + mypy test_simple.py + +In future, this should change to use the test framework used by mypy. diff --git a/tests/test_simple.py b/tests/test_simple.py new file mode 100644 index 0000000..53026e6 --- /dev/null +++ b/tests/test_simple.py @@ -0,0 +1,5 @@ +import numpy as np + +def foo(a : np.ndarray): pass + +foo(np.array(1))