module documentation

Undocumented

Function get_test_cases Undocumented
Function run_mypy Clears the cache and run mypy before running any of the typing tests.
Function strip_func re.sub helper function for stripping module names.
Function test_code_runs Validate that the code in path properly during runtime.
Function test_extended_precision Undocumented
Function test_fail Undocumented
Function test_reveal Validate that mypy correctly infers the return-types of the expressions in path.
Function test_success Undocumented
Constant CACHE_DIR Undocumented
Constant DATA_DIR Undocumented
Constant FAIL_DIR Undocumented
Constant FORMAT_DICT Undocumented
Constant LINENO_MAPPING Undocumented
Constant MISC_DIR Undocumented
Constant MYPY_INI Undocumented
Constant OUTPUT_MYPY Undocumented
Constant PASS_DIR Undocumented
Constant REVEAL_DIR Undocumented
Function _construct_ctypes_dict Undocumented
Function _construct_format_dict Undocumented
Function _key_func Split at the first occurrence of the : character.
Function _parse_reveals

Broken description

Function _strip_filename Strip the filename from a mypy message.
Function _test_fail Undocumented
Function _test_reveal Error-reporting helper function for test_reveal.
Constant _FAIL_MSG1 Undocumented
Constant _FAIL_MSG2 Undocumented
Constant _REVEAL_MSG Undocumented
Constant _STRIP_PATTERN Undocumented
def get_test_cases(directory: str) -> Iterator[ParameterSet]: (source)

Undocumented

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.fixture(scope='module', autouse=True)
def run_mypy(): (source)

Clears the cache and run mypy before running any of the typing tests.

The mypy results are cached in OUTPUT_MYPY for further use.

The cache refresh can be skipped using

NUMPY_TYPING_TEST_CLEAR_CACHE=0 pytest numpy/typing/tests

def strip_func(match: re.Match[str]) -> str: (source)

re.sub helper function for stripping module names.

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.mark.parametrize('path', get_test_cases(PASS_DIR))
def test_code_runs(path: str): (source)

Validate that the code in path properly during runtime.

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
def test_extended_precision(): (source)

Undocumented

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.mark.parametrize('path', get_test_cases(FAIL_DIR))
def test_fail(path: str): (source)

Undocumented

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.mark.parametrize('path', get_test_cases(REVEAL_DIR))
def test_reveal(path: str): (source)

Validate that mypy correctly infers the return-types of the expressions in path.

@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.mark.parametrize('path', get_test_cases(PASS_DIR))
def test_success(path): (source)

Undocumented

CACHE_DIR = (source)

Undocumented

Value
os.path.join(DATA_DIR, '.mypy_cache')
DATA_DIR = (source)

Undocumented

Value
os.path.join(os.path.dirname(__file__), 'data')
FAIL_DIR = (source)

Undocumented

Value
os.path.join(DATA_DIR, 'fail')
FORMAT_DICT: dict[str, str] = (source)

Undocumented

Value
_construct_format_dict()
LINENO_MAPPING: dict[int, str] = (source)

Undocumented

Value
{3: 'uint128',
 4: 'uint256',
 6: 'int128',
 7: 'int256',
 9: 'float80',
 10: 'float96',
 11: 'float128',
...
MISC_DIR = (source)

Undocumented

Value
os.path.join(DATA_DIR, 'misc')
MYPY_INI = (source)

Undocumented

Value
os.path.join(DATA_DIR, 'mypy.ini')
OUTPUT_MYPY: dict[str, list[str]] = (source)

Undocumented

Value
{}
PASS_DIR = (source)

Undocumented

Value
os.path.join(DATA_DIR, 'pass')
REVEAL_DIR = (source)

Undocumented

Value
os.path.join(DATA_DIR, 'reveal')
def _construct_ctypes_dict() -> dict[str, str]: (source)

Undocumented

def _construct_format_dict() -> dict[str, str]: (source)

Undocumented

def _key_func(key: str) -> str: (source)

Split at the first occurrence of the : character.

Windows drive-letters (e.g. C:) are ignored herein.

def _parse_reveals(file: IO[str]) -> tuple[npt.NDArray[np.str_], list[str]]: (source)

Extract and parse all ``" # E: "`` comments from the passed file-like object. All format keys will be substituted for their respective value from `FORMAT_DICT`, *e.g.* ``"{float64}"`` becomes ``"numpy.floating[numpy._typing._64Bit]"``.

def _strip_filename(msg: str) -> str: (source)

Strip the filename from a mypy message.

def _test_fail(path: str, expression: str, error: str, expected_error: None|str, lineno: int): (source)

Undocumented

def _test_reveal(path: str, expression: str, reveal: str, expected_reveal: str, lineno: int): (source)

Error-reporting helper function for test_reveal.

_FAIL_MSG1: str = (source)

Undocumented

Value
'''Extra error at line {}

Expression: {}
Extra error: {!r}
'''
_FAIL_MSG2: str = (source)

Undocumented

Value
'''Error mismatch at line {}

Expression: {}
Expected error: {!r}
Observed error: {!r}
'''
_REVEAL_MSG: str = (source)

Undocumented

Value
'''Reveal mismatch at line {}

Expression: {}
Expected reveal: {!r}
Observed reveal: {!r}
'''
_STRIP_PATTERN = (source)

Undocumented

Value
re.compile(r'(\w+\.)+(\w+)')