Skip to content

Commit

Permalink
Add basic scaffolding for distributing the package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eric-wieser committed Dec 6, 2017
1 parent 88818fe commit cd73c4e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Empty file added numpy/py.typed
Empty file.
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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'
},
)
9 changes: 9 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import numpy as np

def foo(a : np.ndarray): pass

foo(np.array(1))

0 comments on commit cd73c4e

Please sign in to comment.