MCPcopy Create free account
hub / github.com/python/mypy / CFunctionStub

Class CFunctionStub

mypy/stubgenc.py:188–213  ·  view source on GitHub ↗

Class that mimics a C function in order to provide parseable docstrings.

Source from the content-addressed store, hash-verified

186
187
188class CFunctionStub:
189 """
190 Class that mimics a C function in order to provide parseable docstrings.
191 """
192
193 def __init__(self, name: str, doc: str, is_abstract: bool = False) -> None:
194 self.__name__ = name
195 self.__doc__ = doc
196 self.__abstractmethod__ = is_abstract
197
198 @classmethod
199 def _from_sig(cls, sig: FunctionSig, is_abstract: bool = False) -> CFunctionStub:
200 return CFunctionStub(sig.name, sig.format_sig()[:-4], is_abstract)
201
202 @classmethod
203 def _from_sigs(cls, sigs: list[FunctionSig], is_abstract: bool = False) -> CFunctionStub:
204 return CFunctionStub(
205 sigs[0].name, "\n".join(sig.format_sig()[:-4] for sig in sigs), is_abstract
206 )
207
208 def __get__(self) -> None: # noqa: PLE0302
209 """
210 This exists to make this object look like a method descriptor and thus
211 return true for CStubGenerator.ismethod()
212 """
213 pass
214
215
216_Missing = enum.Enum("_Missing", "VALUE")

Callers 3

_from_sigMethod · 0.85
_from_sigsMethod · 0.85
_fix_iterMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…