|
6 | 6 |
|
7 | 7 | import pytest
|
8 | 8 |
|
| 9 | +from types import ModuleType |
| 10 | +from typing import Dict |
| 11 | + |
9 | 12 | from mathics.core.load_builtin import name_is_builtin_symbol
|
10 | 13 | from mathics.core.builtin import Builtin
|
11 | 14 | from mathics.doc.gather import skip_doc
|
|
60 | 63 | language_tool = None
|
61 | 64 | if CHECK_GRAMMAR:
|
62 | 65 | try:
|
63 |
| - import language_tool_python |
| 66 | + import language_tool_python # type: ignore[import-not-found] |
64 | 67 |
|
65 | 68 | language_tool = language_tool_python.LanguageToolPublicAPI("en-US")
|
66 | 69 | # , config={ 'cacheSize': 1000, 'pipelineCaching': True })
|
@@ -95,14 +98,15 @@ def import_module(module_name: str):
|
95 | 98 | module_names.append(f"{subdir}.{modname}")
|
96 | 99 |
|
97 | 100 |
|
98 |
| -modules = dict() |
| 101 | +modules: Dict[str, ModuleType] = dict() |
99 | 102 | for module_name in module_names:
|
100 | 103 | import_module(module_name)
|
101 | 104 |
|
102 | 105 | # modules = {"compilation": modules["compilation"],}
|
103 | 106 |
|
104 | 107 |
|
105 | 108 | def check_grammar(text: str):
|
| 109 | + assert language_tool is not None |
106 | 110 | matches = language_tool.check(text)
|
107 | 111 | filtered_matches = []
|
108 | 112 | if matches:
|
@@ -138,10 +142,10 @@ def check_well_formatted_docstring(docstr: str, instance: Builtin, module_name:
|
138 | 142 | ), f"missing <dd> field {instance.get_name()} from {module_name}"
|
139 | 143 | assert (
|
140 | 144 | docstr.count("</dt>") == 0
|
141 |
| - ), f"unnecesary </dt> {instance.get_name()} from {module_name}" |
| 145 | + ), f"unnecessary </dt> {instance.get_name()} from {module_name}" |
142 | 146 | assert (
|
143 | 147 | docstr.count("</dd>") == 0
|
144 |
| - ), f"unnecesary </dd> field {instance.get_name()} from {module_name}" |
| 148 | + ), f"unnecessary </dd> field {instance.get_name()} from {module_name}" |
145 | 149 |
|
146 | 150 | assert (
|
147 | 151 | docstr.count("<url>") > 0
|
|
0 commit comments