@@ -752,10 +752,14 @@ def __init__(self, filename):
752
752
self .cpp = cpp .Monitor (filename )
753
753
self .cpp .fail = fail
754
754
755
- def parse_line (self , line ) :
755
+ def parse_line (self , line : str ) -> None :
756
756
self .cpp .writeline (line )
757
757
758
- def render (self , clinic , signatures ):
758
+ def render (
759
+ self ,
760
+ clinic : Clinic | None ,
761
+ signatures : Iterable [Function ]
762
+ ) -> str :
759
763
function = None
760
764
for o in signatures :
761
765
if isinstance (o , Function ):
@@ -764,7 +768,10 @@ def render(self, clinic, signatures):
764
768
function = o
765
769
return self .render_function (clinic , function )
766
770
767
- def docstring_for_c_string (self , f ):
771
+ def docstring_for_c_string (
772
+ self ,
773
+ f : Function
774
+ ) -> str :
768
775
if re .search (r'[^\x00-\x7F]' , f .docstring ):
769
776
warn ("Non-ascii character appear in docstring." )
770
777
@@ -1345,7 +1352,7 @@ def parser_body(prototype, *fields, declarations=''):
1345
1352
return d2
1346
1353
1347
1354
@staticmethod
1348
- def group_to_variable_name (group ) :
1355
+ def group_to_variable_name (group : int ) -> str :
1349
1356
adjective = "left_" if group < 0 else "right_"
1350
1357
return "group_" + adjective + str (abs (group ))
1351
1358
@@ -1441,8 +1448,12 @@ def render_option_group_parsing(self, f, template_dict):
1441
1448
add ("}" )
1442
1449
template_dict ['option_group_parsing' ] = format_escape (output ())
1443
1450
1444
- def render_function (self , clinic , f ):
1445
- if not f :
1451
+ def render_function (
1452
+ self ,
1453
+ clinic : Clinic | None ,
1454
+ f : Function | None
1455
+ ) -> str :
1456
+ if f is None or clinic is None :
1446
1457
return ""
1447
1458
1448
1459
add , output = text_accumulator ()
@@ -1504,10 +1515,12 @@ def render_function(self, clinic, f):
1504
1515
1505
1516
template_dict = {}
1506
1517
1518
+ assert isinstance (f .full_name , str )
1507
1519
full_name = f .full_name
1508
1520
template_dict ['full_name' ] = full_name
1509
1521
1510
1522
if new_or_init :
1523
+ assert isinstance (f .cls , Class )
1511
1524
name = f .cls .name
1512
1525
else :
1513
1526
name = f .name
0 commit comments