diff options
author | Matti Picus <matti.picus@gmail.com> | 2021-07-26 09:03:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-26 09:03:19 +0300 |
commit | 978bbe7fdb519edf1f28df4982ce13523ef59a4d (patch) | |
tree | dcb4cd855379d9d7f0562abccb62f64893302a0b | |
parent | e58c1a7f0decf7e43afbdeaa755492e665dd5533 (diff) | |
parent | 77f718c5518b25617dedbfd28d74eabc59764388 (diff) | |
download | numpy-978bbe7fdb519edf1f28df4982ce13523ef59a4d.tar.gz |
Merge pull request #19559 from BvB93/pytest
ENH: Add annotations for `__path__` and `PytestTester`
-rw-r--r-- | numpy/__init__.pyi | 2 | ||||
-rw-r--r-- | numpy/_pytesttester.pyi | 18 | ||||
-rw-r--r-- | numpy/f2py/__init__.pyi | 3 | ||||
-rw-r--r-- | numpy/fft/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/lib/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/linalg/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/ma/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/matrixlib/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/polynomial/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/random/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/testing/__init__.pyi | 4 | ||||
-rw-r--r-- | numpy/typing/__init__.py | 1 | ||||
-rw-r--r-- | numpy/typing/tests/data/reveal/modules.py | 2 |
13 files changed, 58 insertions, 0 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 413a32569..6e27e6047 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -9,6 +9,7 @@ from abc import abstractmethod from types import TracebackType, MappingProxyType from contextlib import ContextDecorator +from numpy._pytesttester import PytestTester from numpy.core.multiarray import flagsobj from numpy.core._internal import _ctypes from numpy.core.getlimits import MachArLike @@ -625,6 +626,7 @@ __all__: List[str] __path__: List[str] __version__: str __git_version__: str +test: PytestTester # TODO: Move placeholders to their respective module once # their annotations are properly implemented diff --git a/numpy/_pytesttester.pyi b/numpy/_pytesttester.pyi new file mode 100644 index 000000000..693f4128a --- /dev/null +++ b/numpy/_pytesttester.pyi @@ -0,0 +1,18 @@ +from typing import List, Iterable +from typing_extensions import Literal as L + +__all__: List[str] + +class PytestTester: + module_name: str + def __init__(self, module_name: str) -> None: ... + def __call__( + self, + label: L["fast", "full"] = ..., + verbose: int = ..., + extra_argv: None | Iterable[str] = ..., + doctests: L[False] = ..., + coverage: bool = ..., + durations: int = ..., + tests: None | Iterable[str] = ..., + ) -> bool: ... diff --git a/numpy/f2py/__init__.pyi b/numpy/f2py/__init__.pyi index b612ce15d..7d8e092ea 100644 --- a/numpy/f2py/__init__.pyi +++ b/numpy/f2py/__init__.pyi @@ -3,6 +3,8 @@ import subprocess from typing import Any, List, Iterable, Dict, overload from typing_extensions import TypedDict, Literal as L +from numpy._pytesttester import PytestTester + class _F2PyDictBase(TypedDict): csrc: List[str] h: List[str] @@ -13,6 +15,7 @@ class _F2PyDict(_F2PyDictBase, total=False): __all__: List[str] __path__: List[str] +test: PytestTester def run_main(comline_list: Iterable[str]) -> Dict[str, _F2PyDict]: ... diff --git a/numpy/fft/__init__.pyi b/numpy/fft/__init__.pyi index 3c191a35f..648b0bf79 100644 --- a/numpy/fft/__init__.pyi +++ b/numpy/fft/__init__.pyi @@ -1,6 +1,10 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + __all__: List[str] +__path__: List[str] +test: PytestTester def fft(a, n=..., axis=..., norm=...): ... def ifft(a, n=..., axis=..., norm=...): ... diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi index bb5224247..25640ec07 100644 --- a/numpy/lib/__init__.pyi +++ b/numpy/lib/__init__.pyi @@ -1,6 +1,8 @@ import math as math from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy import ( ndenumerate as ndenumerate, ndindex as ndindex, @@ -237,6 +239,8 @@ from numpy.core.multiarray import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester __version__ = version emath = scimath diff --git a/numpy/linalg/__init__.pyi b/numpy/linalg/__init__.pyi index 00db05079..7237d865d 100644 --- a/numpy/linalg/__init__.pyi +++ b/numpy/linalg/__init__.pyi @@ -1,6 +1,10 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + __all__: List[str] +__path__: List[str] +test: PytestTester class LinAlgError(Exception): ... diff --git a/numpy/ma/__init__.pyi b/numpy/ma/__init__.pyi index a9a833e52..26d44b508 100644 --- a/numpy/ma/__init__.pyi +++ b/numpy/ma/__init__.pyi @@ -1,5 +1,7 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy.ma import extras as extras from numpy.ma.core import ( @@ -230,3 +232,5 @@ from numpy.ma.extras import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester diff --git a/numpy/matrixlib/__init__.pyi b/numpy/matrixlib/__init__.pyi index e4b5c19a2..26453f000 100644 --- a/numpy/matrixlib/__init__.pyi +++ b/numpy/matrixlib/__init__.pyi @@ -1,10 +1,14 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy import ( matrix as matrix, ) __all__: List[str] +__path__: List[str] +test: PytestTester def bmat(obj, ldict=..., gdict=...): ... def asmatrix(data, dtype=...): ... diff --git a/numpy/polynomial/__init__.pyi b/numpy/polynomial/__init__.pyi index bebedb3a6..e0cfedd7a 100644 --- a/numpy/polynomial/__init__.pyi +++ b/numpy/polynomial/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from numpy.polynomial import ( chebyshev as chebyshev, hermite as hermite, @@ -16,5 +18,7 @@ from numpy.polynomial.legendre import Legendre as Legendre from numpy.polynomial.polynomial import Polynomial as Polynomial __all__: List[str] +__path__: List[str] +test: PytestTester def set_default_printstyle(style): ... diff --git a/numpy/random/__init__.pyi b/numpy/random/__init__.pyi index 48b620c48..bf6147697 100644 --- a/numpy/random/__init__.pyi +++ b/numpy/random/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from numpy.random._generator import Generator as Generator from numpy.random._generator import default_rng as default_rng from numpy.random._mt19937 import MT19937 as MT19937 @@ -66,3 +68,5 @@ from numpy.random.mtrand import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester diff --git a/numpy/testing/__init__.pyi b/numpy/testing/__init__.pyi index 9eaba3deb..def0f9f58 100644 --- a/numpy/testing/__init__.pyi +++ b/numpy/testing/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from unittest import ( TestCase as TestCase, ) @@ -47,6 +49,8 @@ from numpy.testing._private.utils import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester def run_module_suite( file_to_run: None | str = ..., diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py index 05efe61df..d731f00ef 100644 --- a/numpy/typing/__init__.py +++ b/numpy/typing/__init__.py @@ -172,6 +172,7 @@ else: # Declare to mypy that `__all__` is a list of strings without assigning # an explicit value __all__: List[str] + __path__: List[str] @final # Dissallow the creation of arbitrary `NBitBase` subclasses diff --git a/numpy/typing/tests/data/reveal/modules.py b/numpy/typing/tests/data/reveal/modules.py index b045585b2..7e695433e 100644 --- a/numpy/typing/tests/data/reveal/modules.py +++ b/numpy/typing/tests/data/reveal/modules.py @@ -32,6 +32,8 @@ reveal_type(np.polynomial.polynomial) # E: ModuleType reveal_type(np.__path__) # E: list[builtins.str] reveal_type(np.__version__) # E: str reveal_type(np.__git_version__) # E: str +reveal_type(np.test) # E: numpy._pytesttester.PytestTester +reveal_type(np.test.module_name) # E: str reveal_type(np.__all__) # E: list[builtins.str] reveal_type(np.char.__all__) # E: list[builtins.str] |