module documentation

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 NO​_MYPY 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.
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 ​_FAIL​_MSG1 Undocumented
Constant ​_FAIL​_MSG2 Undocumented
Constant ​_REVEAL​_MSG Undocumented
CACHE_DIR =

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

Value
os.path.join(DATA_DIR, 'mypy.ini')
NO_MYPY: bool =

Undocumented

Value
False
OUTPUT_MYPY: dict[str, list[str]] =

Undocumented

Value
{}
PASS_DIR =

Undocumented

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

Undocumented

Value
os.path.join(DATA_DIR, 'reveal')
def _construct_ctypes_dict():

Undocumented

Returns
dict[str, str]Undocumented
def _construct_format_dict():

Undocumented

Returns
dict[str, str]Undocumented
def _key_func(key):

Split at the first occurrence of the : character.

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

Parameters
key:strUndocumented
Returns
strUndocumented
def _parse_reveals(file):

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]"``.

Parameters
file:IO[str]Undocumented
Returns
tuple[npt.NDArray[np.str_], list[str]]Undocumented
def _strip_filename(msg):
Strip the filename from a mypy message.
Parameters
msg:strUndocumented
Returns
strUndocumented
def _test_fail(path, expression, error, expected_error, lineno):

Undocumented

Parameters
path:strUndocumented
expression:strUndocumented
error:strUndocumented
expected​_error:None|strUndocumented
lineno:intUndocumented
def _test_reveal(path, expression, reveal, expected_reveal, lineno):
Error-reporting helper function for test_reveal.
Parameters
path:strUndocumented
expression:strUndocumented
reveal:strUndocumented
expected​_reveal:strUndocumented
lineno:intUndocumented
def get_test_cases(directory):

Undocumented

Parameters
directory:strUndocumented
Returns
Iterator[ParameterSet]Undocumented
@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
@pytest.fixture(scope='module', autouse=True)
def run_mypy():

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.sub helper function for stripping module names.
Parameters
match:re.Match[str]Undocumented
Returns
strUndocumented
@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):
Validate that the code in path properly during runtime.
Parameters
path:strUndocumented
@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason='Mypy is not installed')
def test_extended_precision():

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

Undocumented

Parameters
path:strUndocumented
@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):
Validate that mypy correctly infers the return-types of the expressions in path.
Parameters
path:strUndocumented
@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):

Undocumented

_FAIL_MSG1: str =

Undocumented

Value
'''Extra error at line {}

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

Undocumented

Value
'''Error mismatch at line {}

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

Undocumented

Value
'''Reveal mismatch at line {}

Expression: {}
Expected reveal: {!r}
Observed reveal: {!r}
'''