From eed37234bcb4978476d71a0a92edc5a72b25d352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Sat, 11 Nov 2023 18:37:12 -0300 Subject: [PATCH] Improve error message for tree-sitter not found Raise exception with better error message when tree-sitter is not properly installed --- papyri/ts.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/papyri/ts.py b/papyri/ts.py index c2652d29..c03a942a 100644 --- a/papyri/ts.py +++ b/papyri/ts.py @@ -46,7 +46,13 @@ pth = str(Path(__file__).parent / "rst.so") # replace by tree-sitter-languages once it works See https://github.com/grantjenks/py-tree-sitter-languages/issues/15 -RST = Language(pth, "rst") +try: + RST = Language(pth, "rst") +except OSError as e: + raise OSError( + "tree-sitter-rst not found, rst parsing will not work. Please run `papyri build-parser`" + ) from e + parser = Parser() parser.set_language(RST) log = logging.getLogger("papyri")