diff --git a/explorerscript_parser/__init__.pyi b/explorerscript_parser/__init__.pyi index 642fd71..a845837 100644 --- a/explorerscript_parser/__init__.pyi +++ b/explorerscript_parser/__init__.pyi @@ -780,6 +780,7 @@ class ExplorerScriptBaseVisitor: def visitString_value(self, context: ExplorerScriptParser.String_valueContext) -> Any: ... def visitCtx_header(self, context: ExplorerScriptParser.Ctx_headerContext) -> Any: ... def visitFor_target_def_target(self, context: ExplorerScriptParser.For_target_def_targetContext) -> Any: ... + def visit(self, tree: Antlr4ParseTree) -> Any: ... def visitChildren(self, node: Antlr4ParseTree) -> Any: ... def defaultResult(self) -> Any: ... def aggregateResult(self, aggregate: Any, nextResult: Any) -> Any: ... @@ -1005,6 +1006,7 @@ class SsbScriptBaseVisitor: def visitString_value(self, context: SsbScriptParser.String_valueContext) -> Any: ... def visitCtx_header(self, context: SsbScriptParser.Ctx_headerContext) -> Any: ... def visitFor_target_def_target(self, context: SsbScriptParser.For_target_def_targetContext) -> Any: ... + def visit(self, tree: Antlr4ParseTree) -> Any: ... def visitChildren(self, node: Antlr4ParseTree) -> Any: ... def defaultResult(self) -> Any: ... def aggregateResult(self, aggregate: Any, nextResult: Any) -> Any: ... diff --git a/generate_parser_bindings.py b/generate_parser_bindings.py index ca9e318..cfba81a 100755 --- a/generate_parser_bindings.py +++ b/generate_parser_bindings.py @@ -80,7 +80,9 @@ def generate_bindings(target: str, classes: Classes, visitor_methods: list[Metho f' .def("{method_name}", py::overload_cast<{method["params"].split(' ')[0]}>(&{class_name}::{method_name}), py::return_value_policy::reference_internal)' ) else: - bindings.append(f' .def("{method_name}", py::overload_cast<>(&{class_name}::{method_name}), py::return_value_policy::reference_internal)') + bindings.append( + f' .def("{method_name}", py::overload_cast<>(&{class_name}::{method_name}), py::return_value_policy::reference_internal)' + ) else: method = overloads[0] bindings.append( @@ -89,7 +91,9 @@ def generate_bindings(target: str, classes: Classes, visitor_methods: list[Metho bindings.append(";") - bindings.append(f'py::class_<{target}BaseVisitor, Py{target}BaseVisitor, antlr4::tree::ParseTreeVisitor>(m, "{target}BaseVisitor")') + bindings.append( + f'py::class_<{target}BaseVisitor, Py{target}BaseVisitor, antlr4::tree::ParseTreeVisitor>(m, "{target}BaseVisitor")' + ) bindings.append(" .def(py::init<>())") bindings.append(f' .def("visitChildren", []({target}BaseVisitor& self, antlr4::tree::ParseTree* node) {{') bindings.append(" return std::any_cast(self.visitChildren(node));") @@ -287,6 +291,7 @@ def generate_stubs(target: str, classes: Classes, visitor_methods: list[MethodDe f" def {method['method_name']}(self{maybe_comma}{convert_cpp_sig_to_py(target, method['params'])}) -> {convert_cpp_ty_to_py(target, return_type)}: ..." ) + bindings.append(" def visit(self, tree: Antlr4ParseTree) -> Any: ...") bindings.append(" def visitChildren(self, node: Antlr4ParseTree) -> Any: ...") bindings.append(" def defaultResult(self) -> Any: ...") bindings.append(" def aggregateResult(self, aggregate: Any, nextResult: Any) -> Any: ...") diff --git a/mypy.ini b/mypy.ini index d4770e5..8b6a165 100644 --- a/mypy.ini +++ b/mypy.ini @@ -6,7 +6,4 @@ namespace_packages = True check_untyped_defs = True allow_untyped_defs = False allow_any_generics = False -exclude = explorerscript/antlr - -[mypy-explorerscript.antlr.*] -ignore_errors = True +exclude = antlr4 diff --git a/pyproject.toml b/pyproject.toml index 6b051a0..cd927de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ namespaces = false [tool.ruff] line-length = 120 extend-exclude = [ - "explorerscript/antlr/*" + "antlr4/*" ] [tools.ruff.lint]