Skip to content

Commit

Permalink
Improve error message for tree-sitter not found
Browse files Browse the repository at this point in the history
Raise exception with better error message when tree-sitter is not properly installed
  • Loading branch information
melissawm committed Nov 11, 2023
1 parent ca879e0 commit eed3723
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion papyri/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit eed3723

Please sign in to comment.