From f6c97e6af4d2e7e5d8e53d40860679c4b4fe34b4 Mon Sep 17 00:00:00 2001 From: Davis Chase <130488702+dev2049@users.noreply.github.com> Date: Wed, 10 May 2023 01:07:34 -0700 Subject: [PATCH] Fix Lark import error (#4421) Any import that touches langchain.retrievers currently requires Lark. Here's one attempt to fix. Not very pretty, very open to other ideas. Alternatives I thought of are 1) make Lark requirement, 2) put everything in parser.py in the try/except. Neither sounds much better Related to #4316, #4275 --- langchain/chains/query_constructor/parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/langchain/chains/query_constructor/parser.py b/langchain/chains/query_constructor/parser.py index 22cfc90a56..a0c7f229d9 100644 --- a/langchain/chains/query_constructor/parser.py +++ b/langchain/chains/query_constructor/parser.py @@ -10,7 +10,12 @@ try: ) from lark import Lark, Transformer, v_args except ImportError: - pass + + def v_args(*args: Any, **kwargs: Any) -> Any: # type: ignore + return lambda _: None + + Transformer = object # type: ignore + Lark = object # type: ignore from langchain.chains.query_constructor.ir import ( Comparator,