@@ -530,12 +530,11 @@ class PythonLanguage(Language):
530530 checksum_line = "#/*[{dsl_name} end generated code: {arguments}]*/"
531531
532532
533- ParamGroup = Iterable ["Parameter" ]
534533ParamTuple = tuple ["Parameter" , ...]
535534
536535
537536def permute_left_option_groups (
538- l : Sequence [ParamGroup ]
537+ l : Sequence [Iterable [ Parameter ] ]
539538) -> Iterator [ParamTuple ]:
540539 """
541540 Given [(1,), (2,), (3,)], should yield:
@@ -552,7 +551,7 @@ def permute_left_option_groups(
552551
553552
554553def permute_right_option_groups (
555- l : Sequence [ParamGroup ]
554+ l : Sequence [Iterable [ Parameter ] ]
556555) -> Iterator [ParamTuple ]:
557556 """
558557 Given [(1,), (2,), (3,)], should yield:
@@ -569,9 +568,9 @@ def permute_right_option_groups(
569568
570569
571570def permute_optional_groups (
572- left : Sequence [ParamGroup ],
573- required : ParamGroup ,
574- right : Sequence [ParamGroup ]
571+ left : Sequence [Iterable [ Parameter ] ],
572+ required : Iterable [ Parameter ] ,
573+ right : Sequence [Iterable [ Parameter ] ]
575574) -> tuple [ParamTuple , ...]:
576575 """
577576 Generator function that computes the set of acceptable
@@ -1374,7 +1373,11 @@ def group_to_variable_name(group: int) -> str:
13741373 adjective = "left_" if group < 0 else "right_"
13751374 return "group_" + adjective + str (abs (group ))
13761375
1377- def render_option_group_parsing (self , f , template_dict ):
1376+ def render_option_group_parsing (
1377+ self ,
1378+ f : Function ,
1379+ template_dict : TemplateDict
1380+ ) -> None :
13781381 # positional only, grouped, optional arguments!
13791382 # can be optional on the left or right.
13801383 # here's an example:
@@ -1398,11 +1401,11 @@ def render_option_group_parsing(self, f, template_dict):
13981401 if isinstance (parameters [0 ].converter , self_converter ):
13991402 del parameters [0 ]
14001403
1401- group = None
1404+ group : list [ Parameter ] | None = None
14021405 left = []
14031406 right = []
1404- required = []
1405- last = unspecified
1407+ required : list [ Parameter ] = []
1408+ last : int | Literal [ Sentinels . unspecified ] = unspecified
14061409
14071410 for p in parameters :
14081411 group_id = p .group
@@ -1415,6 +1418,7 @@ def render_option_group_parsing(self, f, template_dict):
14151418 group = required
14161419 else :
14171420 right .append (group )
1421+ assert group is not None
14181422 group .append (p )
14191423
14201424 count_min = sys .maxsize
@@ -1433,19 +1437,21 @@ def render_option_group_parsing(self, f, template_dict):
14331437 continue
14341438
14351439 group_ids = {p .group for p in subset } # eliminate duplicates
1436- d = {}
1440+ d : dict [ str , str | int ] = {}
14371441 d ['count' ] = count
14381442 d ['name' ] = f .name
14391443 d ['format_units' ] = "" .join (p .converter .format_unit for p in subset )
14401444
1441- parse_arguments = []
1445+ parse_arguments : list [ str ] = []
14421446 for p in subset :
14431447 p .converter .parse_argument (parse_arguments )
14441448 d ['parse_arguments' ] = ", " .join (parse_arguments )
14451449
14461450 group_ids .discard (0 )
1447- lines = [self .group_to_variable_name (g ) + " = 1;" for g in group_ids ]
1448- lines = "\n " .join (lines )
1451+ lines = "\n " .join ([
1452+ self .group_to_variable_name (g ) + " = 1;"
1453+ for g in group_ids
1454+ ])
14491455
14501456 s = """\
14511457 case {count}:
0 commit comments