@@ -2640,7 +2640,7 @@ class LandMine:
26402640# try to access any
26412641__message__ :str
26422642
2643- def __getattribute__ (self ,name :str ):
2643+ def __getattribute__ (self ,name :str )-> Any :
26442644if name in ('__repr__' ,'__message__' ):
26452645return super ().__getattribute__ (name )
26462646# raise RuntimeError(repr(name))
@@ -3896,7 +3896,7 @@ def converter_init(self, *, accept: TypeSet = {buffer}) -> None:
38963896
38973897self .format_unit = format_unit
38983898
3899- def cleanup (self ):
3899+ def cleanup (self )-> str :
39003900name = self .name
39013901return "" .join (["if (" ,name ,".obj) {\n PyBuffer_Release(&" ,name ,");\n }\n " ])
39023902
@@ -4115,7 +4115,7 @@ def __init__(
41154115self ,
41164116* ,
41174117py_default :str | None = None ,
4118- ** kwargs
4118+ ** kwargs : Any
41194119 )-> None :
41204120self .py_default = py_default
41214121try :
@@ -4493,7 +4493,7 @@ def directive_destination(
44934493self ,
44944494name :str ,
44954495command :str ,
4496- * args
4496+ * args : str
44974497 )-> None :
44984498match command :
44994499case "new" :
@@ -4847,12 +4847,13 @@ def state_parameters_start(self, line: str | None) -> None:
48474847return self .next (self .state_parameter ,line )
48484848
48494849
4850- def to_required (self ):
4850+ def to_required (self )-> None :
48514851"""
48524852 Transition to the "required" parameter state.
48534853 """
48544854if self .parameter_state is not ParamState .REQUIRED :
48554855self .parameter_state = ParamState .REQUIRED
4856+ assert self .function is not None
48564857for p in self .function .parameters .values ():
48574858p .group = - p .group
48584859
@@ -5000,7 +5001,7 @@ def parse_parameter(self, line: str) -> None:
50005001# of disallowed ast nodes.
50015002class DetectBadNodes (ast .NodeVisitor ):
50025003bad = False
5003- def bad_node (self ,node ) :
5004+ def bad_node (self ,node : ast . AST ) -> None :
50045005self .bad = True
50055006
50065007# inline function call
@@ -5248,7 +5249,9 @@ def state_parameter_docstring_start(self, line: str | None) -> None:
52485249# every line of the docstring must start with at least F spaces,
52495250# where F > P.
52505251# these F spaces will be stripped.
5251- def state_parameter_docstring (self ,line ):
5252+ def state_parameter_docstring (self ,line :str | None )-> None :
5253+ assert line is not None
5254+
52525255stripped = line .strip ()
52535256if stripped .startswith ('#' ):
52545257return
@@ -5263,7 +5266,7 @@ def state_parameter_docstring(self, line):
52635266assert self .indent .depth == 1
52645267return self .next (self .state_function_docstring ,line )
52655268
5266- assert self .function .parameters
5269+ assert self .function and self . function .parameters
52675270last_parameter = next (reversed (list (self .function .parameters .values ())))
52685271
52695272new_docstring = last_parameter .docstring
@@ -5276,7 +5279,10 @@ def state_parameter_docstring(self, line):
52765279last_parameter .docstring = new_docstring
52775280
52785281# the final stanza of the DSL is the docstring.
5279- def state_function_docstring (self ,line ):
5282+ def state_function_docstring (self ,line :str | None )-> None :
5283+ assert self .function is not None
5284+ assert line is not None
5285+
52805286if self .group :
52815287fail ("Function " + self .function .name + " has a ] without a matching [." )
52825288