@@ -154,6 +154,40 @@ def test_subscription_error(self, doctype):
154154 with pytest .raises (lark .exceptions .UnexpectedInput ):
155155 transformer .doctype_to_annotation (doctype )
156156
157+ @pytest .mark .parametrize (
158+ "doctype" ,
159+ [
160+ "Callable[[int], str]" ,
161+ "some_func[[int], str]" ,
162+ "Callable[[int, float, byte], list[str]]" ,
163+ "Callable[..., str]" ,
164+ "Callable[[], str]" ,
165+ "Callback[...]" ,
166+ "Callable[Concatenate[int, float], str]" ,
167+ "Callable[Concatenate[int, ...], str]" ,
168+ "Callable[P, str]" ,
169+ ],
170+ )
171+ def test_callable (self , doctype ):
172+ transformer = DoctypeTransformer ()
173+ annotation , _ = transformer .doctype_to_annotation (doctype )
174+ assert annotation .value == doctype
175+
176+ @pytest .mark .parametrize (
177+ "doctype" ,
178+ [
179+ "Callable[[...], int]" ,
180+ "Callable[[..., str], int]" ,
181+ "Callable[[float, str], int, byte]" ,
182+ "Callable[Ellipsis]" ,
183+ "Callable[Ellipsis, int]" ,
184+ ],
185+ )
186+ def test_callable_error (self , doctype ):
187+ transformer = DoctypeTransformer ()
188+ with pytest .raises (lark .exceptions .UnexpectedInput ):
189+ transformer .doctype_to_annotation (doctype )
190+
157191 @pytest .mark .parametrize (
158192 ("doctype" , "expected" ),
159193 [
0 commit comments