Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Add basic scaffolding for distributing the package #4

Merged
merged 1 commit into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add annotations def __getattr__(name) -> Any: ... to the module and def __getattr__(self, name) -> Any: ... to ndarray/dtype to mark them as flexibly typed.

Copy link
Member Author

@eric-wieser eric-wieser Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean about adding it to the module. Is that supported in type stubs? It's certain not supported in normal python,

I think best to leave them absent anyway, so that adding tests forces us to define the missing fields, rather than things passing silently

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, OK, we can leave it out for now. It is indeed valid in stub files (only).

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))