@@ -752,10 +752,14 @@ def __init__(self, filename):
752752 self .cpp = cpp .Monitor (filename )
753753 self .cpp .fail = fail
754754
755- def parse_line (self , line ) :
755+ def parse_line (self , line : str ) -> None :
756756 self .cpp .writeline (line )
757757
758- def render (self , clinic , signatures ):
758+ def render (
759+ self ,
760+ clinic : Clinic | None ,
761+ signatures : Iterable [Function ]
762+ ) -> str :
759763 function = None
760764 for o in signatures :
761765 if isinstance (o , Function ):
@@ -764,7 +768,10 @@ def render(self, clinic, signatures):
764768 function = o
765769 return self .render_function (clinic , function )
766770
767- def docstring_for_c_string (self , f ):
771+ def docstring_for_c_string (
772+ self ,
773+ f : Function
774+ ) -> str :
768775 if re .search (r'[^\x00-\x7F]' , f .docstring ):
769776 warn ("Non-ascii character appear in docstring." )
770777
@@ -1345,7 +1352,7 @@ def parser_body(prototype, *fields, declarations=''):
13451352 return d2
13461353
13471354 @staticmethod
1348- def group_to_variable_name (group ) :
1355+ def group_to_variable_name (group : int ) -> str :
13491356 adjective = "left_" if group < 0 else "right_"
13501357 return "group_" + adjective + str (abs (group ))
13511358
@@ -1441,8 +1448,12 @@ def render_option_group_parsing(self, f, template_dict):
14411448 add ("}" )
14421449 template_dict ['option_group_parsing' ] = format_escape (output ())
14431450
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 :
14461457 return ""
14471458
14481459 add , output = text_accumulator ()
@@ -1504,10 +1515,12 @@ def render_function(self, clinic, f):
15041515
15051516 template_dict = {}
15061517
1518+ assert isinstance (f .full_name , str )
15071519 full_name = f .full_name
15081520 template_dict ['full_name' ] = full_name
15091521
15101522 if new_or_init :
1523+ assert isinstance (f .cls , Class )
15111524 name = f .cls .name
15121525 else :
15131526 name = f .name
0 commit comments