@@ -234,11 +234,14 @@ def strip_or_import(typ: str, module: ModuleType, imports: List[str]) -> str:
234234 return stripped_type
235235
236236
237- def generate_c_property_stub (name : str , obj : object , output : List [str ], readonly : bool ) -> None :
237+ def generate_c_property_stub (name : str , obj : object , output : List [str ], readonly : bool ,
238+ module : Optional [ModuleType ] = None ,
239+ imports : Optional [List [str ]] = None ) -> None :
238240 """Generate property stub using introspection of 'obj'.
239241
240242 Try to infer type from docstring, append resulting lines to 'output'.
241243 """
244+
242245 def infer_prop_type (docstr : Optional [str ]) -> Optional [str ]:
243246 """Infer property type from docstring or docstring signature."""
244247 if docstr is not None :
@@ -256,6 +259,9 @@ def infer_prop_type(docstr: Optional[str]) -> Optional[str]:
256259 if not inferred :
257260 inferred = 'Any'
258261
262+ if module is not None and imports is not None :
263+ inferred = strip_or_import (inferred , module , imports )
264+
259265 output .append ('@property' )
260266 output .append ('def {}(self) -> {}: ...' .format (name , inferred ))
261267 if not readonly :
@@ -304,7 +310,8 @@ def generate_c_type_stub(module: ModuleType,
304310 class_sigs = class_sigs )
305311 elif is_c_property (value ):
306312 done .add (attr )
307- generate_c_property_stub (attr , value , properties , is_c_property_readonly (value ))
313+ generate_c_property_stub (attr , value , properties , is_c_property_readonly (value ),
314+ module = module , imports = imports )
308315
309316 variables = []
310317 for attr , value in items :
0 commit comments