Skip to content

Commit

Permalink
Compatibility with newest Lark parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 14, 2020
1 parent b2ae7a0 commit 2665393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This patch fixes :func:`~hypothesis.extra.lark.from_lark` with version
0.10.1+ of the :pypi:`lark-parser` package.
9 changes: 8 additions & 1 deletion hypothesis-python/src/hypothesis/extra/lark.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ def __init__(self, grammar, start, explicit):
start = [start]
self.grammar = grammar

if "start" in getfullargspec(grammar.grammar.compile).args:
# This is a total hack, but working around the changes is a nicer user
# experience than breaking for anyone who doesn't instantly update their
# installation of Lark alongside Hypothesis.
compile_args = getfullargspec(grammar.grammar.compile).args
if "terminals_to_keep" in compile_args:
terminals, rules, ignore_names = grammar.grammar.compile(start, ())
elif "start" in compile_args: # pragma: no cover
# Support lark <= 0.10.0, without the terminals_to_keep argument.
terminals, rules, ignore_names = grammar.grammar.compile(start)
else: # pragma: no cover
# This branch is to support lark <= 0.7.1, without the start argument.
Expand Down

0 comments on commit 2665393

Please sign in to comment.