From 12514f9d57e1cc7ccdc0ed3130939effbaaacc80 Mon Sep 17 00:00:00 2001 From: gram Date: Tue, 1 Mar 2022 12:34:30 +0100 Subject: [PATCH 01/10] linter: extract exceptions from docstrings --- deal/linter/_extractors/exceptions.py | 23 +++++++++++++-- .../test_extractors/test_exceptions.py | 28 +++++++++++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index 4ebef176..38f2d68b 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -90,7 +90,7 @@ def _exceptions_from_stubs(expr: astroid.Call, stubs: StubsManager) -> Iterator[ names = stub.get(func=func_name, contract=Category.RAISES) for name in names: name = getattr(builtins, name, name) - yield Token(value=name, line=expr.lineno, col=expr.col_offset) + yield Token(value=name) def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token]: @@ -100,9 +100,10 @@ def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token # recursively infer exceptions from the function body for error in get_exceptions(body=value.body, dive=False): - yield Token(value=error.value, line=expr.lineno, col=expr.col_offset) + yield Token(value=error.value) # get explicitly specified exceptions from `@deal.raises` + name: Optional[str] for contract in get_contracts(value): if contract.name != 'raises': continue @@ -110,5 +111,21 @@ def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token name = get_name(arg) if name is None: continue - yield Token(value=name, line=expr.lineno, col=expr.col_offset) + name = getattr(builtins, name, name) + yield Token(value=name) + + # get exceptions from the docstring + name: str + for name in _excs_from_doc(value.doc): + name = getattr(builtins, name, name) + yield Token(value=name) return None + + +def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: + if doc is None: + return + for line in doc.splitlines(): + words = line.split() + if len(words) >= 2 and words[0] == ':raises': + yield words[1].rstrip(':') diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index d78fdd57..7e0dd8f8 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -132,8 +132,9 @@ def f(): """ tree = ast.parse(dedent(text)) print(ast.dump(tree)) - func_tree = tree.body[-1].body - tuple(get_exceptions(body=func_tree)) + func = tree.body[-1] + assert isinstance(func, ast.FunctionDef) + tuple(get_exceptions(body=func.body)) def test_inference_subcontracts(): @@ -170,3 +171,26 @@ def f(): func_tree = tree.body[-1].body returns = tuple(r.value for r in get_exceptions(body=func_tree)) assert returns == () + + +def test_extract_from_docstring(): + text = """ + def subf(): + ''' + Does not raises RuntimeError. + + :raises ValueError: some junk + :raises KeyError: some junk + ''' + something() + return 1 + + @deal.raises(KeyError) + def f(): + b = subf() + """ + tree = astroid.parse(dedent(text)) + print(tree.repr_tree()) + func_tree = tree.body[-1].body + returns = tuple(r.value for r in get_exceptions(body=func_tree)) + assert returns == (ValueError, KeyError) From e9f3b91db5e992fc638b8b1fc278df3db8fe4181 Mon Sep 17 00:00:00 2001 From: gram Date: Mon, 14 Mar 2022 10:08:29 +0100 Subject: [PATCH 02/10] linter: support more docstring styles --- deal/linter/_extractors/exceptions.py | 31 ++++++++++- .../test_extractors/test_exceptions.py | 52 ++++++++++++++++--- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index 38f2d68b..e74a5064 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -1,5 +1,7 @@ import ast import builtins +import re +from inspect import cleandoc from typing import Iterator, Optional, Union import astroid @@ -11,6 +13,7 @@ get_exceptions = Extractor() +REX_GOOGLE_SECTION = re.compile(r'[A-Z][a-z]+:\s*') @get_exceptions.register(*TOKENS.ASSERT) @@ -125,7 +128,31 @@ def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: if doc is None: return - for line in doc.splitlines(): + section = '' + prev_line = '' + for line in cleandoc(doc).splitlines(): words = line.split() - if len(words) >= 2 and words[0] == ':raises': + if not words: + continue + + # sphinx and epydoc docstring + if len(words) >= 2 and words[0] in (':raises', '@raise'): yield words[1].rstrip(':') + continue + + # google docstring + if REX_GOOGLE_SECTION.fullmatch(line): + section = line.strip().rstrip(':').lower() + continue + indent = len(line) - len(line.lstrip()) + if section == 'raises' and indent == 4: + yield words[0].rstrip(':') + continue + + # numpy docstring + stripped_line = line.strip() + if len(set(stripped_line)) == 1 and stripped_line[0] in '-+': + section = prev_line + prev_line = stripped_line + if section == 'raises' and line == line.lstrip(): + yield line.rstrip() diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index 7e0dd8f8..1d98b82f 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -173,15 +173,50 @@ def f(): assert returns == () -def test_extract_from_docstring(): +@pytest.mark.parametrize('docstring', [ + # sphinx + """Does not raise RuntimeError. + + :raises ValueError: + :raises KeyError: some junk + :returns RuntimeError + """, + # epydoc + """Does not raise RuntimeError. + + @raise ValueError: + @raise KeyError: some junk + @raise: something + @meta RuntimeError + """, + # google + """Does not raise RuntimeError. + + Raises: + ValueError: + some junk + KeyError: some junk + Returns: + RuntimeError + """, + # numpy + """Does not raise RuntimeError. + + Raises: + ------- + ValueError + some junk + KeyError + + Returns: + -------- + RuntimeError + """, +]) +def test_extract_from_docstring(docstring): text = """ def subf(): - ''' - Does not raises RuntimeError. - - :raises ValueError: some junk - :raises KeyError: some junk - ''' + '''{docstring}''' something() return 1 @@ -189,7 +224,8 @@ def subf(): def f(): b = subf() """ - tree = astroid.parse(dedent(text)) + text = dedent(text).format(docstring=docstring) + tree = astroid.parse(text) print(tree.repr_tree()) func_tree = tree.body[-1].body returns = tuple(r.value for r in get_exceptions(body=func_tree)) From fbd067dd78fbb0936a7360d90f2e09f7d1273938 Mon Sep 17 00:00:00 2001 From: gram Date: Mon, 14 Mar 2022 11:33:15 +0100 Subject: [PATCH 03/10] generate stubs for numpy --- deal/linter/stubs/numpy/_globals.json | 7 + deal/linter/stubs/numpy/_pytesttester.json | 19 + deal/linter/stubs/numpy/_version.json | 41 ++ .../stubs/numpy/array_api/_array_object.json | 110 ++++++ .../numpy/array_api/_creation_functions.json | 136 +++++++ .../numpy/array_api/_data_type_functions.json | 23 ++ .../linter/stubs/numpy/array_api/_dtypes.json | 7 + .../array_api/_elementwise_functions.json | 274 +++++++++++++ .../array_api/_statistical_functions.json | 37 ++ deal/linter/stubs/numpy/array_api/linalg.json | 107 +++++ deal/linter/stubs/numpy/array_api/setup.json | 7 + deal/linter/stubs/numpy/conftest.json | 12 + deal/linter/stubs/numpy/core/__init__.json | 18 + deal/linter/stubs/numpy/core/_asarray.json | 7 + deal/linter/stubs/numpy/core/_dtype.json | 24 ++ .../stubs/numpy/core/_dtype_ctypes.json | 38 ++ deal/linter/stubs/numpy/core/_exceptions.json | 12 + deal/linter/stubs/numpy/core/_internal.json | 107 +++++ deal/linter/stubs/numpy/core/_machar.json | 15 + deal/linter/stubs/numpy/core/_methods.json | 58 +++ .../stubs/numpy/core/_type_aliases.json | 12 + .../stubs/numpy/core/_ufunc_config.json | 22 ++ deal/linter/stubs/numpy/core/arrayprint.json | 55 +++ .../linter/stubs/numpy/core/defchararray.json | 47 +++ deal/linter/stubs/numpy/core/einsumfunc.json | 22 ++ deal/linter/stubs/numpy/core/fromnumeric.json | 22 ++ .../stubs/numpy/core/function_base.json | 32 ++ deal/linter/stubs/numpy/core/getlimits.json | 63 +++ deal/linter/stubs/numpy/core/memmap.json | 12 + deal/linter/stubs/numpy/core/numeric.json | 58 +++ .../linter/stubs/numpy/core/numerictypes.json | 8 + deal/linter/stubs/numpy/core/overrides.json | 12 + deal/linter/stubs/numpy/core/records.json | 84 ++++ deal/linter/stubs/numpy/core/setup.json | 77 ++++ .../linter/stubs/numpy/core/setup_common.json | 41 ++ deal/linter/stubs/numpy/core/shape_base.json | 45 +++ deal/linter/stubs/numpy/ctypeslib.json | 12 + deal/linter/stubs/numpy/dual.json | 17 + deal/linter/stubs/numpy/lib/_datasource.json | 123 ++++++ deal/linter/stubs/numpy/lib/_iotools.json | 38 ++ deal/linter/stubs/numpy/lib/_version.json | 12 + deal/linter/stubs/numpy/lib/arraypad.json | 18 + deal/linter/stubs/numpy/lib/arraysetops.json | 32 ++ deal/linter/stubs/numpy/lib/arrayterator.json | 7 + deal/linter/stubs/numpy/lib/format.json | 114 ++++++ .../linter/stubs/numpy/lib/function_base.json | 195 +++++++++ deal/linter/stubs/numpy/lib/histograms.json | 78 ++++ deal/linter/stubs/numpy/lib/index_tricks.json | 32 ++ deal/linter/stubs/numpy/lib/nanfunctions.json | 87 +++++ deal/linter/stubs/numpy/lib/npyio.json | 159 ++++++++ deal/linter/stubs/numpy/lib/polynomial.json | 74 ++++ deal/linter/stubs/numpy/lib/recfunctions.json | 45 +++ deal/linter/stubs/numpy/lib/setup.json | 7 + deal/linter/stubs/numpy/lib/shape_base.json | 55 +++ .../linter/stubs/numpy/lib/stride_tricks.json | 22 ++ deal/linter/stubs/numpy/lib/twodim_base.json | 40 ++ deal/linter/stubs/numpy/lib/type_check.json | 22 ++ deal/linter/stubs/numpy/lib/ufunclike.json | 27 ++ deal/linter/stubs/numpy/lib/user_array.json | 7 + deal/linter/stubs/numpy/lib/utils.json | 77 ++++ deal/linter/stubs/numpy/linalg/linalg.json | 213 ++++++++++ deal/linter/stubs/numpy/linalg/setup.json | 11 + deal/linter/stubs/numpy/ma/bench.json | 34 ++ deal/linter/stubs/numpy/ma/core.json | 369 ++++++++++++++++++ deal/linter/stubs/numpy/ma/extras.json | 84 ++++ deal/linter/stubs/numpy/ma/mrecords.json | 47 +++ deal/linter/stubs/numpy/ma/setup.json | 7 + deal/linter/stubs/numpy/ma/testutils.json | 60 +++ .../stubs/numpy/ma/timer_comparison.json | 56 +++ .../stubs/numpy/polynomial/__init__.json | 10 + .../stubs/numpy/polynomial/_polybase.json | 47 +++ .../stubs/numpy/polynomial/chebyshev.json | 93 +++++ .../stubs/numpy/polynomial/hermite.json | 59 +++ .../stubs/numpy/polynomial/hermite_e.json | 38 ++ .../stubs/numpy/polynomial/laguerre.json | 37 ++ .../stubs/numpy/polynomial/legendre.json | 39 ++ .../stubs/numpy/polynomial/polynomial.json | 37 ++ .../stubs/numpy/polynomial/polyutils.json | 80 ++++ deal/linter/stubs/numpy/polynomial/setup.json | 7 + deal/linter/stubs/numpy/setup.json | 7 + .../test_extractors/test_exceptions.py | 8 +- 81 files changed, 4310 insertions(+), 4 deletions(-) create mode 100644 deal/linter/stubs/numpy/_globals.json create mode 100644 deal/linter/stubs/numpy/_pytesttester.json create mode 100644 deal/linter/stubs/numpy/_version.json create mode 100644 deal/linter/stubs/numpy/array_api/_array_object.json create mode 100644 deal/linter/stubs/numpy/array_api/_creation_functions.json create mode 100644 deal/linter/stubs/numpy/array_api/_data_type_functions.json create mode 100644 deal/linter/stubs/numpy/array_api/_dtypes.json create mode 100644 deal/linter/stubs/numpy/array_api/_elementwise_functions.json create mode 100644 deal/linter/stubs/numpy/array_api/_statistical_functions.json create mode 100644 deal/linter/stubs/numpy/array_api/linalg.json create mode 100644 deal/linter/stubs/numpy/array_api/setup.json create mode 100644 deal/linter/stubs/numpy/conftest.json create mode 100644 deal/linter/stubs/numpy/core/__init__.json create mode 100644 deal/linter/stubs/numpy/core/_asarray.json create mode 100644 deal/linter/stubs/numpy/core/_dtype.json create mode 100644 deal/linter/stubs/numpy/core/_dtype_ctypes.json create mode 100644 deal/linter/stubs/numpy/core/_exceptions.json create mode 100644 deal/linter/stubs/numpy/core/_internal.json create mode 100644 deal/linter/stubs/numpy/core/_machar.json create mode 100644 deal/linter/stubs/numpy/core/_methods.json create mode 100644 deal/linter/stubs/numpy/core/_type_aliases.json create mode 100644 deal/linter/stubs/numpy/core/_ufunc_config.json create mode 100644 deal/linter/stubs/numpy/core/arrayprint.json create mode 100644 deal/linter/stubs/numpy/core/defchararray.json create mode 100644 deal/linter/stubs/numpy/core/einsumfunc.json create mode 100644 deal/linter/stubs/numpy/core/fromnumeric.json create mode 100644 deal/linter/stubs/numpy/core/function_base.json create mode 100644 deal/linter/stubs/numpy/core/getlimits.json create mode 100644 deal/linter/stubs/numpy/core/memmap.json create mode 100644 deal/linter/stubs/numpy/core/numeric.json create mode 100644 deal/linter/stubs/numpy/core/numerictypes.json create mode 100644 deal/linter/stubs/numpy/core/overrides.json create mode 100644 deal/linter/stubs/numpy/core/records.json create mode 100644 deal/linter/stubs/numpy/core/setup.json create mode 100644 deal/linter/stubs/numpy/core/setup_common.json create mode 100644 deal/linter/stubs/numpy/core/shape_base.json create mode 100644 deal/linter/stubs/numpy/ctypeslib.json create mode 100644 deal/linter/stubs/numpy/dual.json create mode 100644 deal/linter/stubs/numpy/lib/_datasource.json create mode 100644 deal/linter/stubs/numpy/lib/_iotools.json create mode 100644 deal/linter/stubs/numpy/lib/_version.json create mode 100644 deal/linter/stubs/numpy/lib/arraypad.json create mode 100644 deal/linter/stubs/numpy/lib/arraysetops.json create mode 100644 deal/linter/stubs/numpy/lib/arrayterator.json create mode 100644 deal/linter/stubs/numpy/lib/format.json create mode 100644 deal/linter/stubs/numpy/lib/function_base.json create mode 100644 deal/linter/stubs/numpy/lib/histograms.json create mode 100644 deal/linter/stubs/numpy/lib/index_tricks.json create mode 100644 deal/linter/stubs/numpy/lib/nanfunctions.json create mode 100644 deal/linter/stubs/numpy/lib/npyio.json create mode 100644 deal/linter/stubs/numpy/lib/polynomial.json create mode 100644 deal/linter/stubs/numpy/lib/recfunctions.json create mode 100644 deal/linter/stubs/numpy/lib/setup.json create mode 100644 deal/linter/stubs/numpy/lib/shape_base.json create mode 100644 deal/linter/stubs/numpy/lib/stride_tricks.json create mode 100644 deal/linter/stubs/numpy/lib/twodim_base.json create mode 100644 deal/linter/stubs/numpy/lib/type_check.json create mode 100644 deal/linter/stubs/numpy/lib/ufunclike.json create mode 100644 deal/linter/stubs/numpy/lib/user_array.json create mode 100644 deal/linter/stubs/numpy/lib/utils.json create mode 100644 deal/linter/stubs/numpy/linalg/linalg.json create mode 100644 deal/linter/stubs/numpy/linalg/setup.json create mode 100644 deal/linter/stubs/numpy/ma/bench.json create mode 100644 deal/linter/stubs/numpy/ma/core.json create mode 100644 deal/linter/stubs/numpy/ma/extras.json create mode 100644 deal/linter/stubs/numpy/ma/mrecords.json create mode 100644 deal/linter/stubs/numpy/ma/setup.json create mode 100644 deal/linter/stubs/numpy/ma/testutils.json create mode 100644 deal/linter/stubs/numpy/ma/timer_comparison.json create mode 100644 deal/linter/stubs/numpy/polynomial/__init__.json create mode 100644 deal/linter/stubs/numpy/polynomial/_polybase.json create mode 100644 deal/linter/stubs/numpy/polynomial/chebyshev.json create mode 100644 deal/linter/stubs/numpy/polynomial/hermite.json create mode 100644 deal/linter/stubs/numpy/polynomial/hermite_e.json create mode 100644 deal/linter/stubs/numpy/polynomial/laguerre.json create mode 100644 deal/linter/stubs/numpy/polynomial/legendre.json create mode 100644 deal/linter/stubs/numpy/polynomial/polynomial.json create mode 100644 deal/linter/stubs/numpy/polynomial/polyutils.json create mode 100644 deal/linter/stubs/numpy/polynomial/setup.json create mode 100644 deal/linter/stubs/numpy/setup.json diff --git a/deal/linter/stubs/numpy/_globals.json b/deal/linter/stubs/numpy/_globals.json new file mode 100644 index 00000000..9a756dbe --- /dev/null +++ b/deal/linter/stubs/numpy/_globals.json @@ -0,0 +1,7 @@ +{ + "_CopyMode.__bool__": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/_pytesttester.json b/deal/linter/stubs/numpy/_pytesttester.json new file mode 100644 index 00000000..5002a632 --- /dev/null +++ b/deal/linter/stubs/numpy/_pytesttester.json @@ -0,0 +1,19 @@ +{ + "PytestTester.__call__": { + "has": [ + "import", + "stdout" + ], + "raises": [ + "AssertionError", + "TypeError", + "ValueError" + ] + }, + "_show_numpy_info": { + "has": [ + "import", + "stdout" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/_version.json b/deal/linter/stubs/numpy/_version.json new file mode 100644 index 00000000..1b8fa6aa --- /dev/null +++ b/deal/linter/stubs/numpy/_version.json @@ -0,0 +1,41 @@ +{ + "git_pieces_from_vcs": { + "has": [ + "stdout" + ], + "raises": [ + "AssertionError", + "NotThisMethod" + ] + }, + "git_versions_from_keywords": { + "has": [ + "stdout" + ], + "raises": [ + "NotThisMethod" + ] + }, + "render": { + "raises": [ + "ValueError" + ] + }, + "run_command": { + "has": [ + "stdout" + ], + "raises": [ + "AssertionError" + ] + }, + "versions_from_parentdir": { + "has": [ + "stdout" + ], + "raises": [ + "NotThisMethod", + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_array_object.json b/deal/linter/stubs/numpy/array_api/_array_object.json new file mode 100644 index 00000000..2c7d6f83 --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_array_object.json @@ -0,0 +1,110 @@ +{ + "Array.T": { + "raises": [ + "ValueError" + ] + }, + "Array.__abs__": { + "raises": [ + "TypeError" + ] + }, + "Array.__array_namespace__": { + "raises": [ + "ValueError" + ] + }, + "Array.__bool__": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "Array.__float__": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "Array.__getitem__": { + "raises": [ + "IndexError" + ] + }, + "Array.__imatmul__": { + "raises": [ + "ValueError" + ] + }, + "Array.__int__": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "Array.__invert__": { + "raises": [ + "TypeError" + ] + }, + "Array.__neg__": { + "raises": [ + "TypeError" + ] + }, + "Array.__new__": { + "raises": [ + "TypeError" + ] + }, + "Array.__pos__": { + "raises": [ + "TypeError" + ] + }, + "Array.__pow__": { + "has": [ + "import" + ] + }, + "Array.__rpow__": { + "has": [ + "import" + ] + }, + "Array.__setitem__": { + "raises": [ + "IndexError" + ] + }, + "Array._check_allowed_dtypes": { + "raises": [ + "TypeError" + ] + }, + "Array._new": { + "raises": [ + "TypeError" + ] + }, + "Array._promote_scalar": { + "raises": [ + "TypeError" + ] + }, + "Array._validate_index": { + "raises": [ + "IndexError" + ] + }, + "Array.mT": { + "has": [ + "import" + ] + }, + "Array.to_device": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_creation_functions.json b/deal/linter/stubs/numpy/array_api/_creation_functions.json new file mode 100644 index 00000000..2ad040a4 --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_creation_functions.json @@ -0,0 +1,136 @@ +{ + "_check_valid_dtype": { + "raises": [ + "ValueError" + ] + }, + "arange": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "asarray": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError", + "OverflowError", + "ValueError" + ] + }, + "empty": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "empty_like": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "eye": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "from_dlpack": { + "has": [ + "import" + ] + }, + "full": { + "has": [ + "import" + ], + "raises": [ + "TypeError", + "ValueError" + ] + }, + "full_like": { + "has": [ + "import" + ], + "raises": [ + "TypeError", + "ValueError" + ] + }, + "linspace": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "meshgrid": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "ones": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "ones_like": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "tril": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "triu": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "zeros": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "zeros_like": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_data_type_functions.json b/deal/linter/stubs/numpy/array_api/_data_type_functions.json new file mode 100644 index 00000000..d39e0005 --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_data_type_functions.json @@ -0,0 +1,23 @@ +{ + "broadcast_arrays": { + "has": [ + "import" + ] + }, + "broadcast_to": { + "has": [ + "import" + ] + }, + "can_cast": { + "raises": [ + "TypeError" + ] + }, + "result_type": { + "raises": [ + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_dtypes.json b/deal/linter/stubs/numpy/array_api/_dtypes.json new file mode 100644 index 00000000..d9655e82 --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_dtypes.json @@ -0,0 +1,7 @@ +{ + "_result_type": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_elementwise_functions.json b/deal/linter/stubs/numpy/array_api/_elementwise_functions.json new file mode 100644 index 00000000..b84f87dc --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_elementwise_functions.json @@ -0,0 +1,274 @@ +{ + "abs": { + "raises": [ + "TypeError" + ] + }, + "acos": { + "raises": [ + "TypeError" + ] + }, + "acosh": { + "raises": [ + "TypeError" + ] + }, + "add": { + "raises": [ + "TypeError" + ] + }, + "asin": { + "raises": [ + "TypeError" + ] + }, + "asinh": { + "raises": [ + "TypeError" + ] + }, + "atan": { + "raises": [ + "TypeError" + ] + }, + "atan2": { + "raises": [ + "TypeError" + ] + }, + "atanh": { + "raises": [ + "TypeError" + ] + }, + "bitwise_and": { + "raises": [ + "TypeError" + ] + }, + "bitwise_invert": { + "raises": [ + "TypeError" + ] + }, + "bitwise_left_shift": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "bitwise_or": { + "raises": [ + "TypeError" + ] + }, + "bitwise_right_shift": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "bitwise_xor": { + "raises": [ + "TypeError" + ] + }, + "ceil": { + "raises": [ + "TypeError" + ] + }, + "cos": { + "raises": [ + "TypeError" + ] + }, + "cosh": { + "raises": [ + "TypeError" + ] + }, + "divide": { + "raises": [ + "TypeError" + ] + }, + "exp": { + "raises": [ + "TypeError" + ] + }, + "expm1": { + "raises": [ + "TypeError" + ] + }, + "floor": { + "raises": [ + "TypeError" + ] + }, + "floor_divide": { + "raises": [ + "TypeError" + ] + }, + "greater": { + "raises": [ + "TypeError" + ] + }, + "greater_equal": { + "raises": [ + "TypeError" + ] + }, + "isfinite": { + "raises": [ + "TypeError" + ] + }, + "isinf": { + "raises": [ + "TypeError" + ] + }, + "isnan": { + "raises": [ + "TypeError" + ] + }, + "less": { + "raises": [ + "TypeError" + ] + }, + "less_equal": { + "raises": [ + "TypeError" + ] + }, + "log": { + "raises": [ + "TypeError" + ] + }, + "log10": { + "raises": [ + "TypeError" + ] + }, + "log1p": { + "raises": [ + "TypeError" + ] + }, + "log2": { + "raises": [ + "TypeError" + ] + }, + "logaddexp": { + "raises": [ + "TypeError" + ] + }, + "logical_and": { + "raises": [ + "TypeError" + ] + }, + "logical_not": { + "raises": [ + "TypeError" + ] + }, + "logical_or": { + "raises": [ + "TypeError" + ] + }, + "logical_xor": { + "raises": [ + "TypeError" + ] + }, + "multiply": { + "raises": [ + "TypeError" + ] + }, + "negative": { + "raises": [ + "TypeError" + ] + }, + "positive": { + "raises": [ + "TypeError" + ] + }, + "pow": { + "raises": [ + "TypeError" + ] + }, + "remainder": { + "raises": [ + "TypeError" + ] + }, + "round": { + "raises": [ + "TypeError" + ] + }, + "sign": { + "raises": [ + "TypeError" + ] + }, + "sin": { + "raises": [ + "TypeError" + ] + }, + "sinh": { + "raises": [ + "TypeError" + ] + }, + "sqrt": { + "raises": [ + "TypeError" + ] + }, + "square": { + "raises": [ + "TypeError" + ] + }, + "subtract": { + "raises": [ + "TypeError" + ] + }, + "tan": { + "raises": [ + "TypeError" + ] + }, + "tanh": { + "raises": [ + "TypeError" + ] + }, + "trunc": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/_statistical_functions.json b/deal/linter/stubs/numpy/array_api/_statistical_functions.json new file mode 100644 index 00000000..521d1a1f --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/_statistical_functions.json @@ -0,0 +1,37 @@ +{ + "max": { + "raises": [ + "TypeError" + ] + }, + "mean": { + "raises": [ + "TypeError" + ] + }, + "min": { + "raises": [ + "TypeError" + ] + }, + "prod": { + "raises": [ + "TypeError" + ] + }, + "std": { + "raises": [ + "TypeError" + ] + }, + "sum": { + "raises": [ + "TypeError" + ] + }, + "var": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/linalg.json b/deal/linter/stubs/numpy/array_api/linalg.json new file mode 100644 index 00000000..526ed5c8 --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/linalg.json @@ -0,0 +1,107 @@ +{ + "_solve": { + "has": [ + "import" + ] + }, + "cholesky": { + "raises": [ + "TypeError" + ] + }, + "cross": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "det": { + "raises": [ + "TypeError" + ] + }, + "eigh": { + "raises": [ + "TypeError" + ] + }, + "eigvalsh": { + "raises": [ + "TypeError" + ] + }, + "inv": { + "raises": [ + "TypeError" + ] + }, + "matmul": { + "raises": [ + "TypeError" + ] + }, + "matrix_norm": { + "raises": [ + "TypeError" + ] + }, + "matrix_power": { + "raises": [ + "TypeError" + ] + }, + "matrix_transpose": { + "raises": [ + "ValueError" + ] + }, + "outer": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "pinv": { + "raises": [ + "TypeError" + ] + }, + "qr": { + "raises": [ + "TypeError" + ] + }, + "slogdet": { + "raises": [ + "TypeError" + ] + }, + "solve": { + "has": [ + "import" + ], + "raises": [ + "TypeError" + ] + }, + "svd": { + "raises": [ + "TypeError" + ] + }, + "tensordot": { + "raises": [ + "TypeError" + ] + }, + "vecdot": { + "raises": [ + "TypeError" + ] + }, + "vector_norm": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/array_api/setup.json b/deal/linter/stubs/numpy/array_api/setup.json new file mode 100644 index 00000000..31a9ab1c --- /dev/null +++ b/deal/linter/stubs/numpy/array_api/setup.json @@ -0,0 +1,7 @@ +{ + "configuration": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/conftest.json b/deal/linter/stubs/numpy/conftest.json new file mode 100644 index 00000000..dec447b0 --- /dev/null +++ b/deal/linter/stubs/numpy/conftest.json @@ -0,0 +1,12 @@ +{ + "check_fpu_mode": { + "raises": [ + "AssertionError" + ] + }, + "pytest_itemcollected": { + "has": [ + "global" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/__init__.json b/deal/linter/stubs/numpy/core/__init__.json new file mode 100644 index 00000000..b8f8ae37 --- /dev/null +++ b/deal/linter/stubs/numpy/core/__init__.json @@ -0,0 +1,18 @@ +{ + "__getattr__": { + "has": [ + "import" + ], + "raises": [ + "AttributeError", + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ufunc_reconstruct": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_asarray.json b/deal/linter/stubs/numpy/core/_asarray.json new file mode 100644 index 00000000..2d7d7b3a --- /dev/null +++ b/deal/linter/stubs/numpy/core/_asarray.json @@ -0,0 +1,7 @@ +{ + "require": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_dtype.json b/deal/linter/stubs/numpy/core/_dtype.json new file mode 100644 index 00000000..c2fdae4f --- /dev/null +++ b/deal/linter/stubs/numpy/core/_dtype.json @@ -0,0 +1,24 @@ +{ + "_construction_repr": { + "raises": [ + "RuntimeError", + "ZeroDivisionError" + ] + }, + "_kind_name": { + "raises": [ + "RuntimeError" + ] + }, + "_name_get": { + "raises": [ + "RuntimeError" + ] + }, + "_scalar_str": { + "raises": [ + "RuntimeError", + "ZeroDivisionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_dtype_ctypes.json b/deal/linter/stubs/numpy/core/_dtype_ctypes.json new file mode 100644 index 00000000..efd21981 --- /dev/null +++ b/deal/linter/stubs/numpy/core/_dtype_ctypes.json @@ -0,0 +1,38 @@ +{ + "_from_ctypes_array": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError", + "TypeError" + ] + }, + "_from_ctypes_structure": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError", + "TypeError" + ] + }, + "_from_ctypes_union": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError", + "TypeError" + ] + }, + "dtype_from_ctypes_type": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError", + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_exceptions.json b/deal/linter/stubs/numpy/core/_exceptions.json new file mode 100644 index 00000000..d2b5b501 --- /dev/null +++ b/deal/linter/stubs/numpy/core/_exceptions.json @@ -0,0 +1,12 @@ +{ + "_UFuncBinaryResolutionError.__init__": { + "raises": [ + "AssertionError" + ] + }, + "_display_as_base": { + "raises": [ + "AssertionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_internal.json b/deal/linter/stubs/numpy/core/_internal.json new file mode 100644 index 00000000..411c035b --- /dev/null +++ b/deal/linter/stubs/numpy/core/_internal.json @@ -0,0 +1,107 @@ +{ + "__dtype_from_pep3118": { + "raises": [ + "NotImplementedError", + "RuntimeError", + "ValueError" + ] + }, + "_array_descr": { + "raises": [ + "ValueError" + ] + }, + "_commastring": { + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "_ctypes.get_as_parameter": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ctypes.get_data": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ctypes.get_shape": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ctypes.get_strides": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ctypes.shape": { + "has": [ + "import" + ] + }, + "_ctypes.strides": { + "has": [ + "import" + ] + }, + "_dtype_from_pep3118": { + "raises": [ + "NotImplementedError", + "RuntimeError", + "ValueError" + ] + }, + "_getfield_is_safe": { + "raises": [ + "TypeError" + ] + }, + "_getintp_ctype": { + "has": [ + "import" + ] + }, + "_makenames_list": { + "raises": [ + "ValueError" + ] + }, + "_newnames": { + "raises": [ + "ValueError" + ] + }, + "_usefields": { + "raises": [ + "ValueError" + ] + }, + "_view_is_safe": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_machar.json b/deal/linter/stubs/numpy/core/_machar.json new file mode 100644 index 00000000..4aad5f64 --- /dev/null +++ b/deal/linter/stubs/numpy/core/_machar.json @@ -0,0 +1,15 @@ +{ + "MachAr.__init__": { + "has": [ + "import" + ] + }, + "MachAr._do_init": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_methods.json b/deal/linter/stubs/numpy/core/_methods.json new file mode 100644 index 00000000..db64383a --- /dev/null +++ b/deal/linter/stubs/numpy/core/_methods.json @@ -0,0 +1,58 @@ +{ + "_clip": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_clip_dep_invoke_with_casting": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_clip_dep_is_scalar_nan": { + "has": [ + "import" + ] + }, + "_count_reduce_items": { + "has": [ + "import" + ] + }, + "_dump": { + "has": [ + "read" + ] + }, + "_mean": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_var": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_type_aliases.json b/deal/linter/stubs/numpy/core/_type_aliases.json new file mode 100644 index 00000000..d8df28e6 --- /dev/null +++ b/deal/linter/stubs/numpy/core/_type_aliases.json @@ -0,0 +1,12 @@ +{ + "_bits_of": { + "raises": [ + "ValueError" + ] + }, + "bitname": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/_ufunc_config.json b/deal/linter/stubs/numpy/core/_ufunc_config.json new file mode 100644 index 00000000..a2a4a0e1 --- /dev/null +++ b/deal/linter/stubs/numpy/core/_ufunc_config.json @@ -0,0 +1,22 @@ +{ + "errstate.__enter__": { + "raises": [ + "ValueError" + ] + }, + "errstate.__exit__": { + "raises": [ + "ValueError" + ] + }, + "setbufsize": { + "raises": [ + "ValueError" + ] + }, + "seterrcall": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/arrayprint.json b/deal/linter/stubs/numpy/core/arrayprint.json new file mode 100644 index 00000000..fd384142 --- /dev/null +++ b/deal/linter/stubs/numpy/core/arrayprint.json @@ -0,0 +1,55 @@ +{ + "FloatingFormat.__init__": { + "raises": [ + "ValueError" + ] + }, + "_TimelikeFormat._format_non_nat": { + "raises": [ + "NotImplementedError" + ] + }, + "_make_options_dict": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_none_or_positive_arg": { + "raises": [ + "ValueError" + ] + }, + "array2string": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "format_float_positional": { + "raises": [ + "ValueError" + ] + }, + "format_float_scientific": { + "raises": [ + "ValueError" + ] + }, + "set_printoptions": { + "raises": [ + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/defchararray.json b/deal/linter/stubs/numpy/core/defchararray.json new file mode 100644 index 00000000..625ae217 --- /dev/null +++ b/deal/linter/stubs/numpy/core/defchararray.json @@ -0,0 +1,47 @@ +{ + "chararray.__array_finalize__": { + "raises": [ + "ValueError" + ] + }, + "chararray.__mul__": { + "raises": [ + "ValueError" + ] + }, + "chararray.__new__": { + "has": [ + "global" + ] + }, + "chararray.__rmul__": { + "raises": [ + "ValueError" + ] + }, + "chararray.isdecimal": { + "raises": [ + "TypeError" + ] + }, + "chararray.isnumeric": { + "raises": [ + "TypeError" + ] + }, + "isdecimal": { + "raises": [ + "TypeError" + ] + }, + "isnumeric": { + "raises": [ + "TypeError" + ] + }, + "multiply": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/einsumfunc.json b/deal/linter/stubs/numpy/core/einsumfunc.json new file mode 100644 index 00000000..98874245 --- /dev/null +++ b/deal/linter/stubs/numpy/core/einsumfunc.json @@ -0,0 +1,22 @@ +{ + "_parse_einsum_input": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "einsum": { + "raises": [ + "KeyError", + "TypeError", + "ValueError" + ] + }, + "einsum_path": { + "raises": [ + "KeyError", + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/fromnumeric.json b/deal/linter/stubs/numpy/core/fromnumeric.json new file mode 100644 index 00000000..054fd14c --- /dev/null +++ b/deal/linter/stubs/numpy/core/fromnumeric.json @@ -0,0 +1,22 @@ +{ + "put": { + "raises": [ + "TypeError" + ] + }, + "resize": { + "raises": [ + "ValueError" + ] + }, + "sum": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/function_base.json b/deal/linter/stubs/numpy/core/function_base.json new file mode 100644 index 00000000..a1a1f1e7 --- /dev/null +++ b/deal/linter/stubs/numpy/core/function_base.json @@ -0,0 +1,32 @@ +{ + "_add_docstring": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "add_newdoc": { + "has": [ + "import" + ] + }, + "geomspace": { + "raises": [ + "ValueError" + ] + }, + "linspace": { + "raises": [ + "ValueError" + ] + }, + "logspace": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/getlimits.json b/deal/linter/stubs/numpy/core/getlimits.json new file mode 100644 index 00000000..9cfb5237 --- /dev/null +++ b/deal/linter/stubs/numpy/core/getlimits.json @@ -0,0 +1,63 @@ +{ + "MachArLike.smallest_subnormal": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_get_machar": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_register_known_types": { + "raises": [ + "ZeroDivisionError" + ] + }, + "finfo.__new__": { + "raises": [ + "ValueError" + ] + }, + "finfo._init": { + "raises": [ + "ValueError" + ] + }, + "finfo.machar": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "finfo.smallest_normal": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "iinfo.__init__": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/memmap.json b/deal/linter/stubs/numpy/core/memmap.json new file mode 100644 index 00000000..881de0ea --- /dev/null +++ b/deal/linter/stubs/numpy/core/memmap.json @@ -0,0 +1,12 @@ +{ + "memmap.__new__": { + "has": [ + "import", + "read" + ], + "raises": [ + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/numeric.json b/deal/linter/stubs/numpy/core/numeric.json new file mode 100644 index 00000000..a5b93b69 --- /dev/null +++ b/deal/linter/stubs/numpy/core/numeric.json @@ -0,0 +1,58 @@ +{ + "base_repr": { + "raises": [ + "ValueError" + ] + }, + "binary_repr": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "convolve": { + "raises": [ + "ValueError" + ] + }, + "cross": { + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "identity": { + "has": [ + "import" + ] + }, + "moveaxis": { + "raises": [ + "ValueError" + ] + }, + "normalize_axis_tuple": { + "raises": [ + "ValueError" + ] + }, + "roll": { + "raises": [ + "ValueError" + ] + }, + "rollaxis": { + "raises": [ + "AxisError" + ] + }, + "tensordot": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/numerictypes.json b/deal/linter/stubs/numpy/core/numerictypes.json new file mode 100644 index 00000000..9d55ad31 --- /dev/null +++ b/deal/linter/stubs/numpy/core/numerictypes.json @@ -0,0 +1,8 @@ +{ + "sctype2char": { + "raises": [ + "KeyError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/overrides.json b/deal/linter/stubs/numpy/core/overrides.json new file mode 100644 index 00000000..7b7b104f --- /dev/null +++ b/deal/linter/stubs/numpy/core/overrides.json @@ -0,0 +1,12 @@ +{ + "array_function_dispatch": { + "raises": [ + "RuntimeError" + ] + }, + "verify_matching_signatures": { + "raises": [ + "RuntimeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/records.json b/deal/linter/stubs/numpy/core/records.json new file mode 100644 index 00000000..68c45ca7 --- /dev/null +++ b/deal/linter/stubs/numpy/core/records.json @@ -0,0 +1,84 @@ +{ + "_deprecate_shape_0_as_None": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "array": { + "has": [ + "read" + ], + "raises": [ + "OSError", + "TypeError", + "ValueError" + ] + }, + "format_parser._parseFormats": { + "raises": [ + "ValueError" + ] + }, + "format_parser._setfieldnames": { + "raises": [ + "NameError", + "ValueError" + ] + }, + "fromarrays": { + "raises": [ + "ValueError" + ] + }, + "fromfile": { + "has": [ + "read" + ], + "raises": [ + "OSError", + "TypeError", + "ValueError" + ] + }, + "fromrecords": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "fromstring": { + "raises": [ + "TypeError" + ] + }, + "recarray.__getattribute__": { + "raises": [ + "AttributeError" + ] + }, + "recarray.__setattr__": { + "raises": [ + "AttributeError" + ] + }, + "record.__getattribute__": { + "raises": [ + "AttributeError" + ] + }, + "record.__setattr__": { + "raises": [ + "AttributeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/setup.json b/deal/linter/stubs/numpy/core/setup.json new file mode 100644 index 00000000..f1c24954 --- /dev/null +++ b/deal/linter/stubs/numpy/core/setup.json @@ -0,0 +1,77 @@ +{ + "CallOnceOnly.check_complex": { + "raises": [ + "AssertionError", + "Error", + "TypeError" + ] + }, + "CallOnceOnly.check_ieee_macros": { + "raises": [ + "AssertionError", + "Error", + "TypeError" + ] + }, + "CallOnceOnly.check_types": { + "raises": [ + "AssertionError", + "Error", + "RuntimeError", + "SystemError", + "TypeError" + ] + }, + "check_math_capabilities": { + "raises": [ + "SystemError" + ] + }, + "check_mathlib": { + "raises": [ + "RuntimeError" + ] + }, + "check_svml_submodule": { + "raises": [ + "RuntimeError" + ] + }, + "check_types": { + "raises": [ + "RuntimeError", + "SystemError" + ] + }, + "configuration": { + "has": [ + "import", + "read", + "stdout", + "write" + ], + "raises": [ + "AssertionError", + "DistutilsFileError", + "RuntimeError", + "SystemError", + "TypeError" + ] + }, + "pythonlib_dir": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "win32_checks": { + "has": [ + "import", + "stdout" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/setup_common.json b/deal/linter/stubs/numpy/core/setup_common.json new file mode 100644 index 00000000..73cbb49e --- /dev/null +++ b/deal/linter/stubs/numpy/core/setup_common.json @@ -0,0 +1,41 @@ +{ + "check_api_version": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "check_for_right_shift_internal_compiler_error": { + "raises": [ + "AssertionError" + ] + }, + "check_long_double_representation": { + "has": [ + "read" + ], + "raises": [ + "ValueError" + ] + }, + "get_api_versions": { + "has": [ + "import" + ] + }, + "long_double_representation": { + "raises": [ + "Error", + "ValueError" + ] + }, + "pyod": { + "has": [ + "read" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/core/shape_base.json b/deal/linter/stubs/numpy/core/shape_base.json new file mode 100644 index 00000000..2164680d --- /dev/null +++ b/deal/linter/stubs/numpy/core/shape_base.json @@ -0,0 +1,45 @@ +{ + "_arrays_for_stack_dispatcher": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_block_check_depths_match": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_block_info_recursion": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_block_setup": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_concatenate_shapes": { + "raises": [ + "ValueError" + ] + }, + "block": { + "raises": [ + "ValueError" + ] + }, + "stack": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ctypeslib.json b/deal/linter/stubs/numpy/ctypeslib.json new file mode 100644 index 00000000..52fdda5b --- /dev/null +++ b/deal/linter/stubs/numpy/ctypeslib.json @@ -0,0 +1,12 @@ +{ + "_ndptr.from_param": { + "raises": [ + "TypeError" + ] + }, + "ndpointer": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/dual.json b/deal/linter/stubs/numpy/dual.json new file mode 100644 index 00000000..11006998 --- /dev/null +++ b/deal/linter/stubs/numpy/dual.json @@ -0,0 +1,17 @@ +{ + "register_func": { + "raises": [ + "ValueError" + ] + }, + "restore_all": { + "raises": [ + "ValueError" + ] + }, + "restore_func": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/_datasource.json b/deal/linter/stubs/numpy/lib/_datasource.json new file mode 100644 index 00000000..55c6ee7d --- /dev/null +++ b/deal/linter/stubs/numpy/lib/_datasource.json @@ -0,0 +1,123 @@ +{ + "DataSource.__del__": { + "has": [ + "import" + ] + }, + "DataSource.__init__": { + "has": [ + "global", + "import" + ], + "raises": [ + "FileExistsError", + "TypeError" + ] + }, + "DataSource._cache": { + "has": [ + "global", + "import", + "read" + ], + "raises": [ + "FileNotFoundError", + "RuntimeError", + "SameFileError", + "SpecialFileError", + "TypeError", + "ValueError", + "message" + ] + }, + "DataSource._findfile": { + "has": [ + "import" + ] + }, + "DataSource._isurl": { + "has": [ + "import" + ], + "raises": [ + "TypeError", + "ValueError" + ] + }, + "DataSource._iszip": { + "raises": [ + "TypeError" + ] + }, + "DataSource._sanitize_relative_path": { + "raises": [ + "TypeError" + ] + }, + "DataSource._splitzipext": { + "raises": [ + "TypeError" + ] + }, + "DataSource.abspath": { + "has": [ + "import" + ], + "raises": [ + "TypeError", + "ValueError" + ] + }, + "DataSource.exists": { + "has": [ + "import" + ] + }, + "DataSource.open": { + "has": [ + "import" + ], + "raises": [ + "FileNotFoundError", + "ValueError" + ] + }, + "Repository.__del__": { + "has": [ + "import" + ] + }, + "Repository.__init__": { + "has": [ + "import" + ] + }, + "Repository._fullpath": { + "raises": [ + "TypeError" + ] + }, + "Repository.abspath": { + "has": [ + "import" + ] + }, + "Repository.exists": { + "has": [ + "import" + ] + }, + "Repository.listdir": { + "has": [ + "import" + ], + "raises": [ + "NotImplementedError" + ] + }, + "_check_mode": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/_iotools.json b/deal/linter/stubs/numpy/lib/_iotools.json new file mode 100644 index 00000000..1bc67c4d --- /dev/null +++ b/deal/linter/stubs/numpy/lib/_iotools.json @@ -0,0 +1,38 @@ +{ + "NameValidator.__init__": { + "raises": [ + "ValueError" + ] + }, + "StringConverter.__init__": { + "raises": [ + "TypeError" + ] + }, + "StringConverter._do_upgrade": { + "raises": [ + "ConverterError", + "ConverterLockError" + ] + }, + "StringConverter._find_map_entry": { + "raises": [ + "LookupError" + ] + }, + "StringConverter._strict_call": { + "raises": [ + "ValueError" + ] + }, + "StringConverter.update": { + "raises": [ + "TypeError" + ] + }, + "str2bool": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/_version.json b/deal/linter/stubs/numpy/lib/_version.json new file mode 100644 index 00000000..201de5e9 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/_version.json @@ -0,0 +1,12 @@ +{ + "NumpyVersion.__init__": { + "raises": [ + "ValueError" + ] + }, + "NumpyVersion._compare": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/arraypad.json b/deal/linter/stubs/numpy/lib/arraypad.json new file mode 100644 index 00000000..fd853481 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/arraypad.json @@ -0,0 +1,18 @@ +{ + "_as_pairs": { + "raises": [ + "ValueError" + ] + }, + "_get_stats": { + "raises": [ + "ValueError" + ] + }, + "pad": { + "raises": [ + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/arraysetops.json b/deal/linter/stubs/numpy/lib/arraysetops.json new file mode 100644 index 00000000..1f4652e8 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/arraysetops.json @@ -0,0 +1,32 @@ +{ + "ediff1d": { + "raises": [ + "TypeError" + ] + }, + "intersect1d": { + "raises": [ + "TypeError" + ] + }, + "setdiff1d": { + "raises": [ + "TypeError" + ] + }, + "setxor1d": { + "raises": [ + "TypeError" + ] + }, + "union1d": { + "raises": [ + "TypeError" + ] + }, + "unique": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/arrayterator.json b/deal/linter/stubs/numpy/lib/arrayterator.json new file mode 100644 index 00000000..f2baa4c7 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/arrayterator.json @@ -0,0 +1,7 @@ +{ + "Arrayterator.__iter__": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/format.json b/deal/linter/stubs/numpy/lib/format.json new file mode 100644 index 00000000..8ca31420 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/format.json @@ -0,0 +1,114 @@ +{ + "_check_version": { + "raises": [ + "ValueError" + ] + }, + "_filter_header": { + "has": [ + "import" + ] + }, + "_read_array_header": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "_read_bytes": { + "raises": [ + "ValueError" + ] + }, + "_wrap_header": { + "has": [ + "import" + ], + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "_wrap_header_guess_version": { + "has": [ + "import" + ], + "raises": [ + "AssertionError", + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_write_array_header": { + "has": [ + "import" + ], + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "dtype_to_descr": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "magic": { + "raises": [ + "ValueError" + ] + }, + "open_memmap": { + "has": [ + "import", + "read" + ], + "raises": [ + "ValueError" + ] + }, + "read_array": { + "has": [ + "import" + ], + "raises": [ + "UnicodeError", + "ValueError" + ] + }, + "read_array_header_1_0": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "read_array_header_2_0": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "read_magic": { + "raises": [ + "ValueError" + ] + }, + "write_array": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/function_base.json b/deal/linter/stubs/numpy/lib/function_base.json new file mode 100644 index 00000000..5b673f08 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/function_base.json @@ -0,0 +1,195 @@ +{ + "_check_interpolation_as_method": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_i0_1": { + "raises": [ + "ZeroDivisionError" + ] + }, + "_parse_gufunc_signature": { + "raises": [ + "ValueError" + ] + }, + "_parse_input_dimensions": { + "raises": [ + "ValueError" + ] + }, + "_quantile": { + "raises": [ + "ValueError" + ] + }, + "_quantile_ureduce_func": { + "raises": [ + "ValueError" + ] + }, + "_update_dim_sizes": { + "raises": [ + "ValueError" + ] + }, + "asarray_chkfinite": { + "raises": [ + "ValueError" + ] + }, + "average": { + "raises": [ + "TypeError", + "ValueError", + "ZeroDivisionError" + ] + }, + "corrcoef": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "cov": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "ZeroDivisionError", + "message" + ] + }, + "delete": { + "raises": [ + "IndexError", + "ValueError" + ] + }, + "diff": { + "raises": [ + "ValueError" + ] + }, + "digitize": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "gradient": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "i0": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "insert": { + "has": [ + "import" + ], + "raises": [ + "IndexError", + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "interp": { + "raises": [ + "ValueError" + ] + }, + "kaiser": { + "raises": [ + "TypeError", + "ZeroDivisionError" + ] + }, + "meshgrid": { + "raises": [ + "ValueError" + ] + }, + "percentile": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "piecewise": { + "raises": [ + "ValueError" + ] + }, + "place": { + "raises": [ + "TypeError" + ] + }, + "quantile": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "rot90": { + "raises": [ + "ValueError" + ] + }, + "select": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "trapz": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "unwrap": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "vectorize.__init__": { + "raises": [ + "ValueError" + ] + }, + "vectorize._get_ufunc_and_otypes": { + "raises": [ + "ValueError" + ] + }, + "vectorize._vectorize_call_with_signature": { + "raises": [ + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/histograms.json b/deal/linter/stubs/numpy/lib/histograms.json new file mode 100644 index 00000000..533d13b3 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/histograms.json @@ -0,0 +1,78 @@ +{ + "_get_bin_edges": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_get_outer_edges": { + "raises": [ + "ValueError" + ] + }, + "_hist_bin_auto": { + "raises": [ + "ZeroDivisionError" + ] + }, + "_hist_bin_fd": { + "raises": [ + "ZeroDivisionError" + ] + }, + "_hist_bin_rice": { + "raises": [ + "ZeroDivisionError" + ] + }, + "_hist_bin_scott": { + "raises": [ + "ZeroDivisionError" + ] + }, + "_hist_bin_stone": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_ravel_and_check_weights": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "histogram": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "histogram_bin_edges": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "histogramdd": { + "raises": [ + "RuntimeError", + "TypeError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/index_tricks.json b/deal/linter/stubs/numpy/lib/index_tricks.json new file mode 100644 index 00000000..9d8a21f1 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/index_tricks.json @@ -0,0 +1,32 @@ +{ + "AxisConcatenator.__getitem__": { + "raises": [ + "ValueError" + ] + }, + "diag_indices_from": { + "raises": [ + "ValueError" + ] + }, + "fill_diagonal": { + "raises": [ + "ValueError" + ] + }, + "ix_": { + "raises": [ + "ValueError" + ] + }, + "ndindex.ndincr": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/nanfunctions.json b/deal/linter/stubs/numpy/lib/nanfunctions.json new file mode 100644 index 00000000..6958577c --- /dev/null +++ b/deal/linter/stubs/numpy/lib/nanfunctions.json @@ -0,0 +1,87 @@ +{ + "_nanmedian_small": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_remove_nan_1d": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "nanargmax": { + "raises": [ + "ValueError" + ] + }, + "nanargmin": { + "raises": [ + "ValueError" + ] + }, + "nanmax": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "nanmean": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "nanmin": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "nanpercentile": { + "raises": [ + "ValueError" + ] + }, + "nanquantile": { + "raises": [ + "ValueError" + ] + }, + "nanstd": { + "raises": [ + "TypeError" + ] + }, + "nanvar": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/npyio.json b/deal/linter/stubs/numpy/lib/npyio.json new file mode 100644 index 00000000..5fad7e5e --- /dev/null +++ b/deal/linter/stubs/numpy/lib/npyio.json @@ -0,0 +1,159 @@ +{ + "BagObj.__getattribute__": { + "raises": [ + "AttributeError" + ] + }, + "NpzFile.__getitem__": { + "raises": [ + "KeyError" + ] + }, + "NpzFile.__init__": { + "has": [ + "import" + ] + }, + "NpzFile.iteritems": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "NpzFile.iterkeys": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_check_nonneg_int": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_ensure_ndmin_ndarray_check_param": { + "raises": [ + "ValueError" + ] + }, + "_read": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_savez": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "fromregex": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "genfromtxt": { + "has": [ + "import" + ], + "raises": [ + "ConverterError", + "NotImplementedError", + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "load": { + "has": [ + "read" + ], + "raises": [ + "ValueError" + ] + }, + "loadtxt": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "recfromcsv": { + "has": [ + "import" + ], + "raises": [ + "ConverterError", + "NotImplementedError", + "TypeError", + "ValueError" + ] + }, + "recfromtxt": { + "has": [ + "import" + ], + "raises": [ + "ConverterError", + "NotImplementedError", + "TypeError", + "ValueError" + ] + }, + "save": { + "has": [ + "read" + ] + }, + "savetxt": { + "has": [ + "read" + ], + "raises": [ + "AttributeError", + "TypeError", + "ValueError", + "error" + ] + }, + "savez": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "savez_compressed": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "zipfile_factory": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/polynomial.json b/deal/linter/stubs/numpy/lib/polynomial.json new file mode 100644 index 00000000..eb27c566 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/polynomial.json @@ -0,0 +1,74 @@ +{ + "poly": { + "raises": [ + "ValueError" + ] + }, + "poly1d.__init__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "poly1d.__pow__": { + "raises": [ + "ValueError" + ] + }, + "poly1d.__setitem__": { + "raises": [ + "ValueError" + ] + }, + "poly1d.coeffs": { + "raises": [ + "AttributeError" + ] + }, + "poly1d.deriv": { + "raises": [ + "ValueError" + ] + }, + "poly1d.integ": { + "raises": [ + "ValueError" + ] + }, + "poly1d.roots": { + "raises": [ + "ValueError" + ] + }, + "polyder": { + "raises": [ + "ValueError" + ] + }, + "polyfit": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "polyint": { + "raises": [ + "ValueError" + ] + }, + "roots": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/recfunctions.json b/deal/linter/stubs/numpy/lib/recfunctions.json new file mode 100644 index 00000000..7f0c366b --- /dev/null +++ b/deal/linter/stubs/numpy/lib/recfunctions.json @@ -0,0 +1,45 @@ +{ + "append_fields": { + "raises": [ + "ValueError" + ] + }, + "apply_along_fields": { + "raises": [ + "NotImplementedError", + "ValueError" + ] + }, + "join_by": { + "raises": [ + "ValueError" + ] + }, + "rec_append_fields": { + "raises": [ + "ValueError" + ] + }, + "rec_join": { + "raises": [ + "ValueError" + ] + }, + "stack_arrays": { + "raises": [ + "TypeError" + ] + }, + "structured_to_unstructured": { + "raises": [ + "NotImplementedError", + "ValueError" + ] + }, + "unstructured_to_structured": { + "raises": [ + "NotImplementedError", + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/setup.json b/deal/linter/stubs/numpy/lib/setup.json new file mode 100644 index 00000000..31a9ab1c --- /dev/null +++ b/deal/linter/stubs/numpy/lib/setup.json @@ -0,0 +1,7 @@ +{ + "configuration": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/shape_base.json b/deal/linter/stubs/numpy/lib/shape_base.json new file mode 100644 index 00000000..30087da3 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/shape_base.json @@ -0,0 +1,55 @@ +{ + "_make_along_axis_idx": { + "raises": [ + "IndexError", + "ValueError" + ] + }, + "apply_along_axis": { + "raises": [ + "ValueError" + ] + }, + "apply_over_axes": { + "raises": [ + "ValueError" + ] + }, + "array_split": { + "raises": [ + "ValueError" + ] + }, + "dsplit": { + "raises": [ + "ValueError" + ] + }, + "hsplit": { + "raises": [ + "ValueError" + ] + }, + "put_along_axis": { + "raises": [ + "IndexError", + "ValueError" + ] + }, + "split": { + "raises": [ + "ValueError" + ] + }, + "take_along_axis": { + "raises": [ + "IndexError", + "ValueError" + ] + }, + "vsplit": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/stride_tricks.json b/deal/linter/stubs/numpy/lib/stride_tricks.json new file mode 100644 index 00000000..2fd07413 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/stride_tricks.json @@ -0,0 +1,22 @@ +{ + "_broadcast_to": { + "raises": [ + "ValueError" + ] + }, + "broadcast_arrays": { + "raises": [ + "ValueError" + ] + }, + "broadcast_to": { + "raises": [ + "ValueError" + ] + }, + "sliding_window_view": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/twodim_base.json b/deal/linter/stubs/numpy/lib/twodim_base.json new file mode 100644 index 00000000..18b9fdb3 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/twodim_base.json @@ -0,0 +1,40 @@ +{ + "diag": { + "raises": [ + "ValueError" + ] + }, + "fliplr": { + "raises": [ + "ValueError" + ] + }, + "flipud": { + "raises": [ + "ValueError" + ] + }, + "histogram2d": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + }, + "tril_indices_from": { + "raises": [ + "ValueError" + ] + }, + "triu_indices_from": { + "raises": [ + "ValueError" + ] + }, + "vander": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/type_check.json b/deal/linter/stubs/numpy/lib/type_check.json new file mode 100644 index 00000000..8989d24f --- /dev/null +++ b/deal/linter/stubs/numpy/lib/type_check.json @@ -0,0 +1,22 @@ +{ + "_getmaxmin": { + "has": [ + "import" + ] + }, + "common_type": { + "raises": [ + "TypeError" + ] + }, + "nan_to_num": { + "has": [ + "import" + ] + }, + "real_if_close": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/ufunclike.json b/deal/linter/stubs/numpy/lib/ufunclike.json new file mode 100644 index 00000000..670a0d6a --- /dev/null +++ b/deal/linter/stubs/numpy/lib/ufunclike.json @@ -0,0 +1,27 @@ +{ + "_deprecate_out_named_y": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_fix_and_maybe_deprecate_out_named_y": { + "raises": [ + "TypeError" + ] + }, + "isneginf": { + "raises": [ + "TypeError" + ] + }, + "isposinf": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/user_array.json b/deal/linter/stubs/numpy/lib/user_array.json new file mode 100644 index 00000000..fc2b5230 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/user_array.json @@ -0,0 +1,7 @@ +{ + "container._scalarfunc": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/lib/utils.json b/deal/linter/stubs/numpy/lib/utils.json new file mode 100644 index 00000000..b0ff8a35 --- /dev/null +++ b/deal/linter/stubs/numpy/lib/utils.json @@ -0,0 +1,77 @@ +{ + "_Deprecate.__call__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_getmembers": { + "has": [ + "import" + ] + }, + "_lookfor_generate_cache": { + "has": [ + "import" + ], + "raises": [ + "TypeError" + ] + }, + "_makenamedict": { + "has": [ + "import" + ] + }, + "_opt_info": { + "has": [ + "import" + ] + }, + "get_include": { + "has": [ + "import" + ], + "raises": [ + "TypeError" + ] + }, + "info": { + "has": [ + "global", + "import" + ] + }, + "lookfor": { + "has": [ + "import", + "stdout" + ], + "raises": [ + "FileExistsError", + "ZeroDivisionError" + ] + }, + "safe_eval": { + "has": [ + "import" + ], + "raises": [ + "AssertionError" + ] + }, + "source": { + "has": [ + "import" + ] + }, + "who": { + "has": [ + "stdout" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/linalg/linalg.json b/deal/linter/stubs/numpy/linalg/linalg.json new file mode 100644 index 00000000..d6788032 --- /dev/null +++ b/deal/linter/stubs/numpy/linalg/linalg.json @@ -0,0 +1,213 @@ +{ + "_assert_2d": { + "raises": [ + "LinAlgError" + ] + }, + "_assert_finite": { + "raises": [ + "LinAlgError" + ] + }, + "_assert_stacked_2d": { + "raises": [ + "LinAlgError" + ] + }, + "_assert_stacked_square": { + "raises": [ + "LinAlgError" + ] + }, + "_commonType": { + "raises": [ + "TypeError" + ] + }, + "_convertarray": { + "raises": [ + "TypeError" + ] + }, + "_multi_dot": { + "raises": [ + "AssertionError" + ] + }, + "_multi_svd_norm": { + "has": [ + "import" + ] + }, + "_raise_linalgerror_eigenvalues_nonconvergence": { + "raises": [ + "LinAlgError" + ] + }, + "_raise_linalgerror_lstsq": { + "raises": [ + "LinAlgError" + ] + }, + "_raise_linalgerror_nonposdef": { + "raises": [ + "LinAlgError" + ] + }, + "_raise_linalgerror_qr": { + "raises": [ + "LinAlgError" + ] + }, + "_raise_linalgerror_singular": { + "raises": [ + "LinAlgError" + ] + }, + "_raise_linalgerror_svd_nonconvergence": { + "raises": [ + "LinAlgError" + ] + }, + "cholesky": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "cond": { + "has": [ + "import" + ], + "raises": [ + "LinAlgError", + "TypeError", + "ValueError", + "ZeroDivisionError" + ] + }, + "det": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "eig": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "eigh": { + "raises": [ + "LinAlgError", + "TypeError", + "ValueError" + ] + }, + "eigvals": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "eigvalsh": { + "raises": [ + "LinAlgError", + "TypeError", + "ValueError" + ] + }, + "inv": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "lstsq": { + "has": [ + "import" + ], + "raises": [ + "LinAlgError", + "RuntimeError", + "TypeError", + "message" + ] + }, + "matrix_power": { + "raises": [ + "LinAlgError", + "NotImplementedError", + "TypeError" + ] + }, + "matrix_rank": { + "has": [ + "import" + ] + }, + "multi_dot": { + "raises": [ + "AssertionError", + "LinAlgError", + "ValueError" + ] + }, + "norm": { + "raises": [ + "TypeError", + "ValueError", + "ZeroDivisionError" + ] + }, + "pinv": { + "has": [ + "import" + ] + }, + "qr": { + "has": [ + "import" + ], + "raises": [ + "LinAlgError", + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "slogdet": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "solve": { + "raises": [ + "LinAlgError", + "TypeError" + ] + }, + "svd": { + "has": [ + "import" + ], + "raises": [ + "LinAlgError", + "TypeError", + "ValueError" + ] + }, + "tensorinv": { + "raises": [ + "ValueError" + ] + }, + "tensorsolve": { + "raises": [ + "LinAlgError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/linalg/setup.json b/deal/linter/stubs/numpy/linalg/setup.json new file mode 100644 index 00000000..6fc16a94 --- /dev/null +++ b/deal/linter/stubs/numpy/linalg/setup.json @@ -0,0 +1,11 @@ +{ + "configuration": { + "has": [ + "import", + "stdout" + ], + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/bench.json b/deal/linter/stubs/numpy/ma/bench.json new file mode 100644 index 00000000..c0c0bd5d --- /dev/null +++ b/deal/linter/stubs/numpy/ma/bench.json @@ -0,0 +1,34 @@ +{ + "compare_functions_1v": { + "has": [ + "stdout" + ], + "raises": [ + "ZeroDivisionError" + ] + }, + "compare_functions_2v": { + "has": [ + "stdout" + ], + "raises": [ + "ZeroDivisionError" + ] + }, + "compare_methods": { + "has": [ + "stdout" + ], + "raises": [ + "ZeroDivisionError" + ] + }, + "timer": { + "has": [ + "stdout" + ], + "raises": [ + "ZeroDivisionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/core.json b/deal/linter/stubs/numpy/ma/core.json new file mode 100644 index 00000000..68787785 --- /dev/null +++ b/deal/linter/stubs/numpy/ma/core.json @@ -0,0 +1,369 @@ +{ + "MaskedArray.__array_finalize__": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "MaskedArray.__array_wrap__": { + "raises": [ + "TypeError" + ] + }, + "MaskedArray.__deepcopy__": { + "has": [ + "import" + ], + "raises": [ + "Error" + ] + }, + "MaskedArray.__float__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.__getitem__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.__idiv__": { + "raises": [ + "ValueError" + ] + }, + "MaskedArray.__ifloordiv__": { + "raises": [ + "ValueError" + ] + }, + "MaskedArray.__int__": { + "raises": [ + "MaskError", + "TypeError" + ] + }, + "MaskedArray.__ipow__": { + "raises": [ + "ValueError" + ] + }, + "MaskedArray.__itruediv__": { + "raises": [ + "ValueError" + ] + }, + "MaskedArray.__new__": { + "raises": [ + "MaskError", + "TypeError", + "ValueError" + ] + }, + "MaskedArray.__pow__": { + "raises": [ + "MaskError" + ] + }, + "MaskedArray.__rpow__": { + "raises": [ + "MaskError" + ] + }, + "MaskedArray.__setitem__": { + "raises": [ + "MaskError", + "NotImplementedError", + "ValueError" + ] + }, + "MaskedArray._comparison": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "MaskedArray.argpartition": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.fill_value": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "MaskedArray.filled": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "MaskedArray.max": { + "raises": [ + "MaskError" + ] + }, + "MaskedArray.mean": { + "raises": [ + "ZeroDivisionError" + ] + }, + "MaskedArray.min": { + "raises": [ + "MaskError" + ] + }, + "MaskedArray.mini": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.partition": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.recordmask": { + "raises": [ + "NotImplementedError" + ] + }, + "MaskedArray.resize": { + "raises": [ + "ValueError" + ] + }, + "MaskedArray.tofile": { + "raises": [ + "NotImplementedError" + ] + }, + "MaskedArray.tostring": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedArray.var": { + "raises": [ + "MaskError", + "ValueError" + ] + }, + "MaskedConstant.__format__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "MaskedConstant.__setattr__": { + "raises": [ + "AttributeError" + ] + }, + "_check_fill_value": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_convert2ma._replace_return_type": { + "raises": [ + "RuntimeError" + ] + }, + "_deprecate_argsort_axis": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_extrema_operation.__call__": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_extrema_operation.reduce": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_extremum_fill_value": { + "raises": [ + "TypeError" + ] + }, + "_pickle_warn": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "allclose": { + "raises": [ + "ValueError" + ] + }, + "allequal": { + "raises": [ + "ValueError" + ] + }, + "choose": { + "raises": [ + "ValueError" + ] + }, + "dot": { + "raises": [ + "NotImplementedError" + ] + }, + "fromfile": { + "raises": [ + "NotImplementedError" + ] + }, + "mask_or": { + "raises": [ + "ValueError" + ] + }, + "mask_rowcols": { + "raises": [ + "NotImplementedError" + ] + }, + "masked_equal": { + "raises": [ + "IndexError" + ] + }, + "masked_greater": { + "raises": [ + "IndexError" + ] + }, + "masked_greater_equal": { + "raises": [ + "IndexError" + ] + }, + "masked_inside": { + "raises": [ + "IndexError" + ] + }, + "masked_less": { + "raises": [ + "IndexError" + ] + }, + "masked_less_equal": { + "raises": [ + "IndexError" + ] + }, + "masked_not_equal": { + "raises": [ + "IndexError" + ] + }, + "masked_object": { + "raises": [ + "ValueError" + ] + }, + "masked_outside": { + "raises": [ + "IndexError" + ] + }, + "masked_where": { + "raises": [ + "IndexError", + "ValueError" + ] + }, + "maximum_fill_value": { + "raises": [ + "TypeError" + ] + }, + "minimum_fill_value": { + "raises": [ + "TypeError" + ] + }, + "power": { + "raises": [ + "MaskError", + "ValueError" + ] + }, + "where": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/extras.json b/deal/linter/stubs/numpy/ma/extras.json new file mode 100644 index 00000000..326bfff0 --- /dev/null +++ b/deal/linter/stubs/numpy/ma/extras.json @@ -0,0 +1,84 @@ +{ + "MAxisConcatenator.__getitem__": { + "raises": [ + "MAError" + ] + }, + "_covhelper": { + "raises": [ + "ValueError" + ] + }, + "apply_over_axes": { + "raises": [ + "ValueError" + ] + }, + "average": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "compress_cols": { + "raises": [ + "NotImplementedError" + ] + }, + "compress_rowcols": { + "raises": [ + "NotImplementedError" + ] + }, + "compress_rows": { + "raises": [ + "NotImplementedError" + ] + }, + "corrcoef": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "cov": { + "raises": [ + "ValueError" + ] + }, + "mask_cols": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "mask_rows": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "notmasked_contiguous": { + "raises": [ + "NotImplementedError" + ] + }, + "polyfit": { + "raises": [ + "TypeError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/mrecords.json b/deal/linter/stubs/numpy/ma/mrecords.json new file mode 100644 index 00000000..fd5ba391 --- /dev/null +++ b/deal/linter/stubs/numpy/ma/mrecords.json @@ -0,0 +1,47 @@ +{ + "MaskedRecords.__getattribute__": { + "raises": [ + "AttributeError", + "NotImplementedError" + ] + }, + "MaskedRecords.__new__": { + "raises": [ + "MAError" + ] + }, + "MaskedRecords.__setattr__": { + "raises": [ + "AttributeError" + ] + }, + "_checknames": { + "raises": [ + "NameError" + ] + }, + "_guessvartypes": { + "raises": [ + "ValueError" + ] + }, + "fromtextfile": { + "has": [ + "import" + ], + "raises": [ + "FileNotFoundError", + "NotImplementedError", + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "openfile": { + "raises": [ + "FileNotFoundError", + "NotImplementedError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/setup.json b/deal/linter/stubs/numpy/ma/setup.json new file mode 100644 index 00000000..31a9ab1c --- /dev/null +++ b/deal/linter/stubs/numpy/ma/setup.json @@ -0,0 +1,7 @@ +{ + "configuration": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/testutils.json b/deal/linter/stubs/numpy/ma/testutils.json new file mode 100644 index 00000000..4d084db3 --- /dev/null +++ b/deal/linter/stubs/numpy/ma/testutils.json @@ -0,0 +1,60 @@ +{ + "_assert_equal_on_sequences": { + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "assert_almost_equal": { + "raises": [ + "AssertionError" + ] + }, + "assert_array_almost_equal": { + "raises": [ + "ValueError" + ] + }, + "assert_array_approx_equal": { + "raises": [ + "ValueError" + ] + }, + "assert_array_compare": { + "raises": [ + "ValueError" + ] + }, + "assert_array_equal": { + "raises": [ + "ValueError" + ] + }, + "assert_array_less": { + "raises": [ + "ValueError" + ] + }, + "assert_equal": { + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "assert_equal_records": { + "raises": [ + "AssertionError", + "ValueError" + ] + }, + "fail_if_array_equal": { + "raises": [ + "ValueError" + ] + }, + "fail_if_equal": { + "raises": [ + "AssertionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/ma/timer_comparison.json b/deal/linter/stubs/numpy/ma/timer_comparison.json new file mode 100644 index 00000000..ce1e8daa --- /dev/null +++ b/deal/linter/stubs/numpy/ma/timer_comparison.json @@ -0,0 +1,56 @@ +{ + "ModuleTester.assert_array_compare": { + "raises": [ + "ValueError" + ] + }, + "ModuleTester.test_0": { + "raises": [ + "ZeroDivisionError" + ] + }, + "ModuleTester.test_1": { + "raises": [ + "AssertionError", + "TypeError", + "ZeroDivisionError" + ] + }, + "ModuleTester.test_2": { + "raises": [ + "AssertionError" + ] + }, + "ModuleTester.test_3": { + "raises": [ + "AssertionError" + ] + }, + "ModuleTester.test_4": { + "raises": [ + "AssertionError" + ] + }, + "ModuleTester.test_5": { + "raises": [ + "AssertionError", + "ZeroDivisionError" + ] + }, + "ModuleTester.test_6": { + "raises": [ + "AssertionError" + ] + }, + "ModuleTester.test_7": { + "raises": [ + "ZeroDivisionError" + ] + }, + "ModuleTester.test_99": { + "raises": [ + "AssertionError", + "ZeroDivisionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/__init__.json b/deal/linter/stubs/numpy/polynomial/__init__.json new file mode 100644 index 00000000..292e9be3 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/__init__.json @@ -0,0 +1,10 @@ +{ + "set_default_printstyle": { + "has": [ + "import" + ], + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/_polybase.json b/deal/linter/stubs/numpy/polynomial/_polybase.json new file mode 100644 index 00000000..1a049a14 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/_polybase.json @@ -0,0 +1,47 @@ +{ + "ABCPolyBase.__format__": { + "raises": [ + "ValueError" + ] + }, + "ABCPolyBase.__init__": { + "raises": [ + "ValueError" + ] + }, + "ABCPolyBase.__truediv__": { + "raises": [ + "TypeError" + ] + }, + "ABCPolyBase._get_coefficients": { + "raises": [ + "TypeError" + ] + }, + "ABCPolyBase._repr_latex_term": { + "raises": [ + "NotImplementedError" + ] + }, + "ABCPolyBase._str_term_ascii": { + "raises": [ + "NotImplementedError" + ] + }, + "ABCPolyBase._str_term_unicode": { + "raises": [ + "NotImplementedError" + ] + }, + "ABCPolyBase.basis": { + "raises": [ + "ValueError" + ] + }, + "ABCPolyBase.truncate": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/chebyshev.json b/deal/linter/stubs/numpy/polynomial/chebyshev.json new file mode 100644 index 00000000..b0e156cd --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/chebyshev.json @@ -0,0 +1,93 @@ +{ + "Chebyshev.interpolate": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_cseries_to_zseries": { + "raises": [ + "ZeroDivisionError" + ] + }, + "cheb2poly": { + "has": [ + "import" + ] + }, + "chebcompanion": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "chebder": { + "raises": [ + "ValueError" + ] + }, + "chebdiv": { + "raises": [ + "ZeroDivisionError" + ] + }, + "chebgauss": { + "raises": [ + "ValueError" + ] + }, + "chebint": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "chebinterpolate": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "chebmul": { + "raises": [ + "ZeroDivisionError" + ] + }, + "chebmulx": { + "raises": [ + "ZeroDivisionError" + ] + }, + "chebpow": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "chebpts1": { + "raises": [ + "ValueError" + ] + }, + "chebpts2": { + "raises": [ + "ValueError" + ] + }, + "chebroots": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "chebvander": { + "raises": [ + "ValueError" + ] + }, + "poly2cheb": { + "raises": [ + "ZeroDivisionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/hermite.json b/deal/linter/stubs/numpy/polynomial/hermite.json new file mode 100644 index 00000000..5c630be2 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/hermite.json @@ -0,0 +1,59 @@ +{ + "herm2poly": { + "has": [ + "import" + ] + }, + "hermcompanion": { + "raises": [ + "ValueError" + ] + }, + "hermder": { + "raises": [ + "ValueError" + ] + }, + "hermgauss": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "hermint": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "hermline": { + "raises": [ + "ZeroDivisionError" + ] + }, + "hermmul": { + "raises": [ + "ZeroDivisionError" + ] + }, + "hermmulx": { + "raises": [ + "ZeroDivisionError" + ] + }, + "hermroots": { + "raises": [ + "ValueError" + ] + }, + "hermvander": { + "raises": [ + "ValueError" + ] + }, + "poly2herm": { + "raises": [ + "ZeroDivisionError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/hermite_e.json b/deal/linter/stubs/numpy/polynomial/hermite_e.json new file mode 100644 index 00000000..d59fe8c0 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/hermite_e.json @@ -0,0 +1,38 @@ +{ + "herme2poly": { + "has": [ + "import" + ] + }, + "hermecompanion": { + "raises": [ + "ValueError" + ] + }, + "hermeder": { + "raises": [ + "ValueError" + ] + }, + "hermegauss": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "hermeint": { + "raises": [ + "ValueError" + ] + }, + "hermeroots": { + "raises": [ + "ValueError" + ] + }, + "hermevander": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/laguerre.json b/deal/linter/stubs/numpy/polynomial/laguerre.json new file mode 100644 index 00000000..347f4999 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/laguerre.json @@ -0,0 +1,37 @@ +{ + "lag2poly": { + "has": [ + "import" + ] + }, + "lagcompanion": { + "raises": [ + "ValueError" + ] + }, + "lagder": { + "raises": [ + "ValueError" + ] + }, + "laggauss": { + "raises": [ + "ValueError" + ] + }, + "lagint": { + "raises": [ + "ValueError" + ] + }, + "lagroots": { + "raises": [ + "ValueError" + ] + }, + "lagvander": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/legendre.json b/deal/linter/stubs/numpy/polynomial/legendre.json new file mode 100644 index 00000000..082a4890 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/legendre.json @@ -0,0 +1,39 @@ +{ + "leg2poly": { + "has": [ + "import" + ] + }, + "legcompanion": { + "raises": [ + "ValueError" + ] + }, + "legder": { + "raises": [ + "ValueError" + ] + }, + "leggauss": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "legint": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "legroots": { + "raises": [ + "ValueError" + ] + }, + "legvander": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/polynomial.json b/deal/linter/stubs/numpy/polynomial/polynomial.json new file mode 100644 index 00000000..03a15fef --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/polynomial.json @@ -0,0 +1,37 @@ +{ + "polycompanion": { + "raises": [ + "ValueError" + ] + }, + "polyder": { + "raises": [ + "ValueError" + ] + }, + "polydiv": { + "raises": [ + "ZeroDivisionError" + ] + }, + "polyint": { + "raises": [ + "ValueError" + ] + }, + "polyroots": { + "raises": [ + "ValueError" + ] + }, + "polyvalfromroots": { + "raises": [ + "ValueError" + ] + }, + "polyvander": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/polyutils.json b/deal/linter/stubs/numpy/polynomial/polyutils.json new file mode 100644 index 00000000..7a8a6546 --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/polyutils.json @@ -0,0 +1,80 @@ +{ + "_add": { + "raises": [ + "ValueError" + ] + }, + "_deprecate_as_int": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "message" + ] + }, + "_div": { + "raises": [ + "ValueError", + "ZeroDivisionError" + ] + }, + "_fit": { + "has": [ + "import" + ], + "raises": [ + "RuntimeError", + "TypeError", + "ValueError", + "message" + ] + }, + "_fromroots": { + "raises": [ + "ValueError" + ] + }, + "_pow": { + "raises": [ + "ValueError" + ] + }, + "_sub": { + "raises": [ + "ValueError" + ] + }, + "_valnd": { + "raises": [ + "ValueError" + ] + }, + "_vander_nd": { + "raises": [ + "TypeError", + "ValueError" + ] + }, + "_vander_nd_flat": { + "raises": [ + "ValueError" + ] + }, + "as_series": { + "raises": [ + "ValueError" + ] + }, + "getdomain": { + "raises": [ + "ValueError" + ] + }, + "trimcoef": { + "raises": [ + "ValueError" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/polynomial/setup.json b/deal/linter/stubs/numpy/polynomial/setup.json new file mode 100644 index 00000000..31a9ab1c --- /dev/null +++ b/deal/linter/stubs/numpy/polynomial/setup.json @@ -0,0 +1,7 @@ +{ + "configuration": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/deal/linter/stubs/numpy/setup.json b/deal/linter/stubs/numpy/setup.json new file mode 100644 index 00000000..31a9ab1c --- /dev/null +++ b/deal/linter/stubs/numpy/setup.json @@ -0,0 +1,7 @@ +{ + "configuration": { + "has": [ + "import" + ] + } +} \ No newline at end of file diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index 1d98b82f..e395290c 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -202,14 +202,14 @@ def f(): # numpy """Does not raise RuntimeError. - Raises: - ------- + Raises + ------ ValueError some junk KeyError - Returns: - -------- + Returns + ------- RuntimeError """, ]) From 50deebf02a90767235c420eff518014ef83ff0d5 Mon Sep 17 00:00:00 2001 From: gram Date: Mon, 14 Mar 2022 12:50:18 +0100 Subject: [PATCH 04/10] improve numpy stubs --- deal/linter/_extractors/exceptions.py | 30 ++++++++++++------- deal/linter/stubs/numpy/core/arrayprint.json | 10 +++++++ deal/linter/stubs/numpy/core/numeric.json | 2 ++ .../linter/stubs/numpy/lib/stride_tricks.json | 5 ++++ deal/linter/stubs/numpy/linalg/linalg.json | 10 +++++++ deal/linter/stubs/numpy/ma/core.json | 21 +++++++++++-- 6 files changed, 66 insertions(+), 12 deletions(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index e74a5064..2a5d2d14 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -2,6 +2,7 @@ import builtins import re from inspect import cleandoc +from itertools import zip_longest from typing import Iterator, Optional, Union import astroid @@ -128,9 +129,10 @@ def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: if doc is None: return - section = '' - prev_line = '' - for line in cleandoc(doc).splitlines(): + google_section = '' + numpy_section = '' + lines = cleandoc(doc).splitlines() + for line, next_line in zip_longest(lines, lines[1:]): words = line.split() if not words: continue @@ -142,17 +144,25 @@ def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: # google docstring if REX_GOOGLE_SECTION.fullmatch(line): - section = line.strip().rstrip(':').lower() + google_section = line.strip().rstrip(':').lower() continue indent = len(line) - len(line.lstrip()) - if section == 'raises' and indent == 4: + if google_section == 'raises' and indent == 4: yield words[0].rstrip(':') continue # numpy docstring - stripped_line = line.strip() - if len(set(stripped_line)) == 1 and stripped_line[0] in '-+': - section = prev_line - prev_line = stripped_line - if section == 'raises' and line == line.lstrip(): + if next_line is not None: + next_line = next_line.strip() + if _is_header_highlight(next_line): + numpy_section = line.strip().rstrip(':').lower() + continue + if _is_header_highlight(line): + continue + if numpy_section == 'raises' and line == line.lstrip() and indent == 0: yield line.rstrip() + + +def _is_header_highlight(line: str) -> bool: + line = line.strip() + return len(set(line)) == 1 and line[0] in '-+' diff --git a/deal/linter/stubs/numpy/core/arrayprint.json b/deal/linter/stubs/numpy/core/arrayprint.json index fd384142..badd3244 100644 --- a/deal/linter/stubs/numpy/core/arrayprint.json +++ b/deal/linter/stubs/numpy/core/arrayprint.json @@ -9,6 +9,16 @@ "NotImplementedError" ] }, + "_array_repr_implementation": { + "raises": [ + "TypeError" + ] + }, + "_array_str_implementation": { + "raises": [ + "TypeError" + ] + }, "_make_options_dict": { "has": [ "import" diff --git a/deal/linter/stubs/numpy/core/numeric.json b/deal/linter/stubs/numpy/core/numeric.json index a5b93b69..a4ac75f7 100644 --- a/deal/linter/stubs/numpy/core/numeric.json +++ b/deal/linter/stubs/numpy/core/numeric.json @@ -32,6 +32,7 @@ }, "moveaxis": { "raises": [ + "AxisError", "ValueError" ] }, @@ -42,6 +43,7 @@ }, "roll": { "raises": [ + "AxisError", "ValueError" ] }, diff --git a/deal/linter/stubs/numpy/lib/stride_tricks.json b/deal/linter/stubs/numpy/lib/stride_tricks.json index 2fd07413..efb58cab 100644 --- a/deal/linter/stubs/numpy/lib/stride_tricks.json +++ b/deal/linter/stubs/numpy/lib/stride_tricks.json @@ -1,4 +1,9 @@ { + "_broadcast_shape": { + "raises": [ + "ValueError" + ] + }, "_broadcast_to": { "raises": [ "ValueError" diff --git a/deal/linter/stubs/numpy/linalg/linalg.json b/deal/linter/stubs/numpy/linalg/linalg.json index d6788032..135d50e2 100644 --- a/deal/linter/stubs/numpy/linalg/linalg.json +++ b/deal/linter/stubs/numpy/linalg/linalg.json @@ -37,6 +37,9 @@ "_multi_svd_norm": { "has": [ "import" + ], + "raises": [ + "LinAlgError" ] }, "_raise_linalgerror_eigenvalues_nonconvergence": { @@ -145,6 +148,9 @@ "matrix_rank": { "has": [ "import" + ], + "raises": [ + "LinAlgError" ] }, "multi_dot": { @@ -164,6 +170,9 @@ "pinv": { "has": [ "import" + ], + "raises": [ + "LinAlgError" ] }, "qr": { @@ -202,6 +211,7 @@ }, "tensorinv": { "raises": [ + "LinAlgError", "ValueError" ] }, diff --git a/deal/linter/stubs/numpy/ma/core.json b/deal/linter/stubs/numpy/ma/core.json index 68787785..6ecb89fe 100644 --- a/deal/linter/stubs/numpy/ma/core.json +++ b/deal/linter/stubs/numpy/ma/core.json @@ -94,6 +94,16 @@ "ValueError" ] }, + "MaskedArray.argmax": { + "raises": [ + "TypeError" + ] + }, + "MaskedArray.argmin": { + "raises": [ + "TypeError" + ] + }, "MaskedArray.argpartition": { "has": [ "import" @@ -104,6 +114,11 @@ "message" ] }, + "MaskedArray.argsort": { + "raises": [ + "TypeError" + ] + }, "MaskedArray.fill_value": { "has": [ "import" @@ -123,7 +138,8 @@ }, "MaskedArray.max": { "raises": [ - "MaskError" + "MaskError", + "TypeError" ] }, "MaskedArray.mean": { @@ -133,7 +149,8 @@ }, "MaskedArray.min": { "raises": [ - "MaskError" + "MaskError", + "TypeError" ] }, "MaskedArray.mini": { From d62dfde8ef88893449f6a787861953078cc9c989 Mon Sep 17 00:00:00 2001 From: gram Date: Mon, 14 Mar 2022 13:23:41 +0100 Subject: [PATCH 05/10] describe markers application --- docs/details/recipes.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/details/recipes.md b/docs/details/recipes.md index 69a536ad..ba7ef5da 100644 --- a/docs/details/recipes.md +++ b/docs/details/recipes.md @@ -83,6 +83,18 @@ You can use any logic inside the validator. However, thumb up rule is to keep co The `message` argument should tell what is expected behavior without assuming that the user violated it. This is because the users can encounter it not only when a `ContractError` is raised but also when they just read the source code or [generated documentation](./docs). For example, if your contract checks that `b >= 0`, don't say "b is negative" (what is violated), say "b must be non-negative" (what is expected). +## Markers are not only side-effects + +The `@deal.has` decorator is used to track markers. Some of the markers describing side-effects (like `stdout`) are predefined and detected by linter and in runtime. However, markers can be also used to track anything else you'd like to track in your code. A few examples: + ++ Functions that are usually slow. ++ Functions that can be called only for a user with admin access. ++ Functions that access the database. ++ Functions that access the patient data. ++ Functions that can only work with some additional dependencies installed. ++ Deprecated functions. ++ Functions that need refactoring. + ## Permissive license Deal is distributed under [MIT License](https://en.wikipedia.org/wiki/MIT_License) which is a permissive license with high [license compatibility](https://en.wikipedia.org/wiki/License_compatibility). However, Deal has [astroid](https://github.com/PyCQA/astroid) in the dependencies which is licensed under [LGPL](https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License). While this license allows to be used in non-LGPL proprietary software too, it still can be not enough for some companies. So, if the legal department in your company forbids using LGPL libraries in transitive dependencies, you can freely remove `astroid` from the project dependencies before shipping it on the production. All CLI commands won't work anymore but runtime checks will. From 784fc25a13338ce33772e3b42d0e116126402af8 Mon Sep 17 00:00:00 2001 From: gram Date: Tue, 15 Mar 2022 17:46:57 +0100 Subject: [PATCH 06/10] use docstring_parser if available --- deal/linter/_extractors/exceptions.py | 14 +++ pyproject.toml | 2 + .../test_extractors/test_exceptions.py | 106 ++++++++++++------ 3 files changed, 88 insertions(+), 34 deletions(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index 2a5d2d14..96c419bb 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -12,6 +12,11 @@ from .common import TOKENS, Extractor, Token, get_full_name, get_name, get_stub, infer from .contracts import get_contracts +try: + import docstring_parser +except ImportError: + docstring_parser = None # type: ignore[assignment] + get_exceptions = Extractor() REX_GOOGLE_SECTION = re.compile(r'[A-Z][a-z]+:\s*') @@ -126,9 +131,18 @@ def _exceptions_from_func(expr: Union[ast.Call, astroid.Call]) -> Iterator[Token return None +# TODO: use it on the target function docstring too def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: if doc is None: return + + if docstring_parser is not None: + parsed = docstring_parser.parse(doc) + for exc_info in parsed.raises: + if exc_info.type_name: + yield exc_info.type_name + return + google_section = '' numpy_section = '' lines = cleandoc(doc).splitlines() diff --git a/pyproject.toml b/pyproject.toml index 30b48c21..0f15d2e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ requires = [ [tool.flit.metadata.requires-extra] all = [ "deal-solver", + "docstring-parser", "hypothesis", "pygments", "typeguard", @@ -46,6 +47,7 @@ test = [ # copy-pasted "all" extra "deal-solver", + "docstring-parser", "hypothesis", "pygments", "typeguard", diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index e395290c..d0b0caf4 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -1,5 +1,7 @@ import ast +import sys from textwrap import dedent +from typing import Dict import astroid import pytest @@ -173,47 +175,83 @@ def f(): assert returns == () +@pytest.fixture +def remove_import(): + old_imports: Dict[str, Dict[str, object]] = dict() + + def _remove_import(what: str): + old_imports[what] = dict() + for mod_name, module in sys.modules.items(): + if not mod_name.startswith('deal.'): + continue + if not hasattr(module, what): + continue + old_imports[what][mod_name] = getattr(module, what) + setattr(module, what, None) + yield _remove_import + + for what, imports in old_imports.items(): + for mod_name, old_import in imports.items(): + module = sys.modules[mod_name] + setattr(module, what, old_import) + + @pytest.mark.parametrize('docstring', [ # sphinx - """Does not raise RuntimeError. - - :raises ValueError: - :raises KeyError: some junk - :returns RuntimeError - """, + pytest.param( + """Does not raise RuntimeError. + + :raises ValueError: + :raises KeyError: some junk + :returns: RuntimeError + """, + id="sphinx", + ), # epydoc - """Does not raise RuntimeError. - - @raise ValueError: - @raise KeyError: some junk - @raise: something - @meta RuntimeError - """, + pytest.param( + """Does not raise RuntimeError. + + @raise ValueError: + @raise KeyError: some junk + @raise: something + @return: RuntimeError + """, + id="epydoc", + ), # google - """Does not raise RuntimeError. + pytest.param( + """Does not raise RuntimeError. + + Raises: + ValueError: + some junk + KeyError: some junk + Returns: + RuntimeError + """, + id="google", + ), + # numpy + pytest.param( + """Does not raise RuntimeError. - Raises: - ValueError: - some junk - KeyError: some junk - Returns: + Raises + ------ + ValueError + some junk + KeyError + + Returns + ------- RuntimeError - """, - # numpy - """Does not raise RuntimeError. - - Raises - ------ - ValueError - some junk - KeyError - - Returns - ------- - RuntimeError - """, + """, + id="numpy", + ), ]) -def test_extract_from_docstring(docstring): +@pytest.mark.parametrize('patch_third_party', [True, False]) +def test_extract_from_docstring(docstring, patch_third_party, remove_import): + if patch_third_party: + remove_import('docstring_parser') text = """ def subf(): '''{docstring}''' From 9b72e3b4118bf2e17983134f8babd7fb1ad3458c Mon Sep 17 00:00:00 2001 From: gram Date: Wed, 16 Mar 2022 10:20:11 +0100 Subject: [PATCH 07/10] run docstring-parser test cases --- pyproject.toml | 3 +- .../test_extractors/test_exceptions.py | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0f15d2e2..0cc079b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,13 +31,13 @@ requires = [ [tool.flit.metadata.requires-extra] all = [ "deal-solver", - "docstring-parser", "hypothesis", "pygments", "typeguard", ] test = [ "coverage[toml]", + "docstring-parser", "isort", "marshmallow", "pytest-cov", @@ -47,7 +47,6 @@ test = [ # copy-pasted "all" extra "deal-solver", - "docstring-parser", "hypothesis", "pygments", "typeguard", diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index d0b0caf4..72b8a786 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -1,12 +1,15 @@ import ast +from pathlib import Path import sys from textwrap import dedent from typing import Dict import astroid +import docstring_parser import pytest from deal.linter._extractors import get_exceptions +from deal.linter._extractors.exceptions import _excs_from_doc @pytest.mark.parametrize('text, expected', [ @@ -268,3 +271,48 @@ def f(): func_tree = tree.body[-1].body returns = tuple(r.value for r in get_exceptions(body=func_tree)) assert returns == (ValueError, KeyError) + + +def get_docstring_parser_tests(): + """Extract test cases from docstring_parser/tests. + """ + root = Path(docstring_parser.__path__[0]) / 'tests' + tests_found = 0 + for path in root.iterdir(): + if path.suffix != '.py': + continue + tree = astroid.parse(code=path.read_text(), path=str(path)) + assert isinstance(tree, astroid.Module) + for func in tree.body: + if not isinstance(func, astroid.FunctionDef): + continue + if not func.decorators: + continue + assert isinstance(func.decorators, astroid.Decorators) + for dec in func.decorators.nodes: + if not isinstance(dec, astroid.Call): + continue + if dec.func.as_string() != 'pytest.mark.parametrize': + continue + cases = dec.args[1] + assert isinstance(cases, astroid.List) + for case in cases.elts: + assert isinstance(case, astroid.Tuple) + given = case.elts[0] + if not isinstance(given, astroid.Const): + continue + yield pytest.param(given.value, id=f'{path.name}:{given.lineno}') + tests_found += 1 + assert tests_found > 10 + + +@pytest.mark.parametrize('docstring', get_docstring_parser_tests()) +def test_compare_with_docstring_parser(docstring, remove_import): + """ + Run test cases from docstring_parser and run extractor with and without + docstring_parser. The result must be the same. + """ + theirs = list(_excs_from_doc(docstring)) + remove_import('docstring_parser') + ours = list(_excs_from_doc(docstring)) + assert theirs == ours From fe1738095557839960ebe0e1c2bd73a622dfd436 Mon Sep 17 00:00:00 2001 From: gram Date: Wed, 16 Mar 2022 10:28:08 +0100 Subject: [PATCH 08/10] account for running indent in docstrings --- deal/linter/_extractors/exceptions.py | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index 96c419bb..d86962fc 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -2,7 +2,6 @@ import builtins import re from inspect import cleandoc -from itertools import zip_longest from typing import Iterator, Optional, Union import astroid @@ -145,11 +144,15 @@ def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: google_section = '' numpy_section = '' - lines = cleandoc(doc).splitlines() - for line, next_line in zip_longest(lines, lines[1:]): + google_section_indent = 4 + numpy_section_indent = 0 + lines = cleandoc(doc).splitlines() + [''] + for line, next_line in zip(lines, lines[1:]): words = line.split() if not words: continue + indent = _get_indent(line) + is_numpy_header = _is_header_highlight(next_line) # sphinx and epydoc docstring if len(words) >= 2 and words[0] in (':raises', '@raise'): @@ -157,26 +160,30 @@ def _excs_from_doc(doc: Optional[str]) -> Iterator[str]: continue # google docstring - if REX_GOOGLE_SECTION.fullmatch(line): + if REX_GOOGLE_SECTION.fullmatch(line) and not is_numpy_header: google_section = line.strip().rstrip(':').lower() + google_section_indent = _get_indent(next_line) continue - indent = len(line) - len(line.lstrip()) - if google_section == 'raises' and indent == 4: + if google_section == 'raises' and indent == google_section_indent: yield words[0].rstrip(':') continue # numpy docstring - if next_line is not None: - next_line = next_line.strip() - if _is_header_highlight(next_line): - numpy_section = line.strip().rstrip(':').lower() - continue + next_line = next_line.strip() + if is_numpy_header: + numpy_section = line.strip().rstrip(':').lower() + continue if _is_header_highlight(line): + numpy_section_indent = _get_indent(next_line) continue - if numpy_section == 'raises' and line == line.lstrip() and indent == 0: + if numpy_section == 'raises' and indent == numpy_section_indent: yield line.rstrip() +def _get_indent(line: str) -> int: + return len(line) - len(line.lstrip()) + + def _is_header_highlight(line: str) -> bool: line = line.strip() return len(set(line)) == 1 and line[0] in '-+' From 2e024d7fc948b2dc4682f3d14f4a4f583195cde0 Mon Sep 17 00:00:00 2001 From: gram Date: Wed, 16 Mar 2022 10:29:00 +0100 Subject: [PATCH 09/10] use single quotes --- tests/test_linter/test_extractors/test_exceptions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_linter/test_extractors/test_exceptions.py b/tests/test_linter/test_extractors/test_exceptions.py index 72b8a786..f2a9fd21 100644 --- a/tests/test_linter/test_extractors/test_exceptions.py +++ b/tests/test_linter/test_extractors/test_exceptions.py @@ -208,7 +208,7 @@ def _remove_import(what: str): :raises KeyError: some junk :returns: RuntimeError """, - id="sphinx", + id='sphinx', ), # epydoc pytest.param( @@ -219,7 +219,7 @@ def _remove_import(what: str): @raise: something @return: RuntimeError """, - id="epydoc", + id='epydoc', ), # google pytest.param( @@ -232,7 +232,7 @@ def _remove_import(what: str): Returns: RuntimeError """, - id="google", + id='google', ), # numpy pytest.param( @@ -248,7 +248,7 @@ def _remove_import(what: str): ------- RuntimeError """, - id="numpy", + id='numpy', ), ]) @pytest.mark.parametrize('patch_third_party', [True, False]) From 2d8ba8c03e84f734cbd13f45f391b1d24267dfb0 Mon Sep 17 00:00:00 2001 From: gram Date: Wed, 16 Mar 2022 11:16:45 +0100 Subject: [PATCH 10/10] drop unused `# type: ignore` --- deal/linter/_extractors/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deal/linter/_extractors/exceptions.py b/deal/linter/_extractors/exceptions.py index d86962fc..c1872717 100644 --- a/deal/linter/_extractors/exceptions.py +++ b/deal/linter/_extractors/exceptions.py @@ -14,7 +14,7 @@ try: import docstring_parser except ImportError: - docstring_parser = None # type: ignore[assignment] + docstring_parser = None get_exceptions = Extractor()