File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -173,20 +173,20 @@ def transform(self, tree):
173173 finally :
174174 self ._collected_imports = None
175175
176- def doctype (self , tree ):
176+ def annotation (self , tree ):
177177 out = " | " .join (tree .children )
178178 return out
179179
180- def type_or (self , tree ):
180+ def types_or (self , tree ):
181181 out = " | " .join (tree .children )
182182 return out
183183
184184 def optional (self , tree ):
185185 out = "None"
186186 literal = [child for child in tree .children if child .type == "LITERAL" ]
187187 assert len (literal ) <= 1
188- if len ( literal ) == 1 :
189- out = lark .Discard # Should be covered by doctype
188+ if literal :
189+ out = lark .Discard # Type should cover the default
190190 return out
191191
192192 def extra_info (self , tree ):
Original file line number Diff line number Diff line change 1- ? start : doctype
1+ ? start : annotation
22
3- doctype : type_or (" ," optional )? (" ," extra_info )?
3+ annotation : ( literals | types_or ) (" ," optional )? (" ," extra_info )?
44
5- type_or : type ((" or" | " |" ) type )*
5+ literals : " {" literal (" ," literal )* " }"
6+
7+ types_or : type ((" or" | " |" ) type )*
68
79? type : qualname
810 | sphinx_ref
9- | " {" literal (" ," literal )* " }" -> literals
1011 | shape_n_dtype
1112
1213optional : " optional"
@@ -19,11 +20,11 @@ sphinx_ref : ":" (NAME ":")? NAME ":`" qualname "`"
1920// Name with leading dot separated path
2021qualname : (/ ~/ " ." )? (NAME " ." )* NAME contains ?
2122
22- contains : " [" type_or (" ," type_or )* " ]"
23- | " [" type_or " ," PY_ELLIPSES " ]"
23+ contains : " [" types_or (" ," types_or )* " ]"
24+ | " [" types_or " ," PY_ELLIPSES " ]"
2425 | " of" type
25- | " of" " (" type_or (" ," type_or )* " )"
26- | " of" " {" type_or " :" type_or " }"
26+ | " of" " (" types_or (" ," types_or )* " )"
27+ | " of" " {" types_or " :" types_or " }"
2728
2829// Array-like form with dtype or shape information
2930shape_n_dtype : shape ? ARRAY_NAME (" of" dtype )?
You can’t perform that action at this time.
0 commit comments