44# Copyright 2012-2013 by Larry Hastings.
55# Licensed to the PSF under a contributor agreement.
66#
7+ from __future__ import annotations
78
89import abc
910import ast
@@ -2448,7 +2449,7 @@ def __init__(
24482449 cls : Class | None = None ,
24492450 c_basename : str | None = None ,
24502451 full_name : str | None = None ,
2451- return_converter : ReturnConverterType ,
2452+ return_converter : CReturnConverter ,
24522453 return_annotation = inspect .Signature .empty ,
24532454 docstring : str | None = None ,
24542455 kind : str = CALLABLE ,
@@ -2467,7 +2468,7 @@ def __init__(
24672468 self .docstring = docstring or ''
24682469 self .kind = kind
24692470 self .coexist = coexist
2470- self .self_converter = None
2471+ self .self_converter : self_converter | None = None
24712472 # docstring_only means "don't generate a machine-readable
24722473 # signature, just a normal docstring". it's True for
24732474 # functions with optional groups because we can't represent
@@ -2531,7 +2532,7 @@ class Parameter:
25312532 def __init__ (
25322533 self ,
25332534 name : str ,
2534- kind : str ,
2535+ kind : inspect . _ParameterKind ,
25352536 * ,
25362537 default = inspect .Parameter .empty ,
25372538 function : Function ,
@@ -4539,7 +4540,7 @@ def state_dsl_start(self, line: str | None) -> None:
45394540
45404541 self .next (self .state_modulename_name , line )
45414542
4542- def state_modulename_name (self , line ) :
4543+ def state_modulename_name (self , line : str | None ) -> None :
45434544 # looking for declaration, which establishes the leftmost column
45444545 # line should be
45454546 # modulename.fnname [as c_basename] [-> return annotation]
@@ -4556,13 +4557,14 @@ def state_modulename_name(self, line):
45564557 # this line is permitted to start with whitespace.
45574558 # we'll call this number of spaces F (for "function").
45584559
4559- if not line . strip ( ):
4560+ if not self . valid_line ( line ):
45604561 return
45614562
45624563 self .indent .infer (line )
45634564
45644565 # are we cloning?
45654566 before , equals , existing = line .rpartition ('=' )
4567+ c_basename : str | None
45664568 if equals :
45674569 full_name , _ , c_basename = before .partition (' as ' )
45684570 full_name = full_name .strip ()
@@ -4665,8 +4667,9 @@ def state_modulename_name(self, line):
46654667 if cls and type == "PyObject *" :
46664668 kwargs ['type' ] = cls .typedef
46674669 sc = self .function .self_converter = self_converter (name , name , self .function , ** kwargs )
4668- p_self = Parameter (sc .name , inspect .Parameter .POSITIONAL_ONLY , function = self .function , converter = sc )
4669- self .function .parameters [sc .name ] = p_self
4670+ p_self = Parameter (name , inspect .Parameter .POSITIONAL_ONLY ,
4671+ function = self .function , converter = sc )
4672+ self .function .parameters [name ] = p_self
46704673
46714674 (cls or module ).functions .append (self .function )
46724675 self .next (self .state_parameters_start )
@@ -4740,7 +4743,7 @@ def state_modulename_name(self, line):
47404743 ps_start , ps_left_square_before , ps_group_before , ps_required , \
47414744 ps_optional , ps_group_after , ps_right_square_after = range (7 )
47424745
4743- def state_parameters_start (self , line : str ) -> None :
4746+ def state_parameters_start (self , line : str | None ) -> None :
47444747 if not self .valid_line (line ):
47454748 return
47464749
0 commit comments