From 11b95d15f10c2bc652ed19d5e27efa0384396cb8 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Sat, 6 Jun 2020 15:31:33 -0700 Subject: ENH: add type stubs from numpy-stubs Add the type stubs and tests from numpy-stubs. Things this entails: - Copy over the stubs (numpy/__init__.pyi and numpy/core/_internal.pyi) - The only modification made was removing `ndarray.tostring` since it is deprecated - Update some setup.py files to include pyi files - Move the tests from numpy-stubs/tests into numpy/tests - Skip them if mypy is not installed (planning on setting up CI in a future PR) - Add a mypy.ini; use it to configure mypy in the tests - It tells mypy where to find NumPy in the test env - It ignores internal NumPy type errors (since we only want to consider errors from the tests cases) - Some small edits were made to fix test cases that were emitting deprecation warnings - Add numpy/py.typed so that the types are picked up in an installed version of NumPy --- numpy/tests/reveal/warnings_and_errors.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 numpy/tests/reveal/warnings_and_errors.py (limited to 'numpy/tests/reveal/warnings_and_errors.py') diff --git a/numpy/tests/reveal/warnings_and_errors.py b/numpy/tests/reveal/warnings_and_errors.py new file mode 100644 index 000000000..c428deb7a --- /dev/null +++ b/numpy/tests/reveal/warnings_and_errors.py @@ -0,0 +1,10 @@ +from typing import Type + +import numpy as np + +reveal_type(np.ModuleDeprecationWarning()) # E: numpy.ModuleDeprecationWarning +reveal_type(np.VisibleDeprecationWarning()) # E: numpy.VisibleDeprecationWarning +reveal_type(np.ComplexWarning()) # E: numpy.ComplexWarning +reveal_type(np.RankWarning()) # E: numpy.RankWarning +reveal_type(np.TooHardError()) # E: numpy.TooHardError +reveal_type(np.AxisError(1)) # E: numpy.AxisError -- cgit v1.2.1