(
self, default_sig: FunctionSig, ctx: FunctionContext
)
| 106 | |
| 107 | class DocstringSignatureGenerator(SignatureGenerator): |
| 108 | def get_function_sig( |
| 109 | self, default_sig: FunctionSig, ctx: FunctionContext |
| 110 | ) -> list[FunctionSig] | None: |
| 111 | inferred = infer_sig_from_docstring(ctx.docstring, ctx.name) |
| 112 | if inferred: |
| 113 | assert ctx.docstring is not None |
| 114 | if is_pybind11_overloaded_function_docstring(ctx.docstring, ctx.name): |
| 115 | # Remove pybind11 umbrella (*args, **kwargs) for overloaded functions |
| 116 | del inferred[-1] |
| 117 | |
| 118 | if ctx.class_info: |
| 119 | if not inferred and ctx.name == "__init__": |
| 120 | # look for class-level constructor signatures of the form <class_name>(<signature>) |
| 121 | inferred = infer_sig_from_docstring(ctx.class_info.docstring, ctx.class_info.name) |
| 122 | if inferred: |
| 123 | inferred = [sig._replace(name="__init__") for sig in inferred] |
| 124 | return self.remove_self_type(inferred, ctx.class_info.self_var) |
| 125 | else: |
| 126 | return inferred |
| 127 | |
| 128 | def get_property_type(self, default_type: str | None, ctx: FunctionContext) -> str | None: |
| 129 | """Infer property type from docstring or docstring signature.""" |
nothing calls this directly
no test coverage detected