Mutable duck type for inspect.Function. docstring - a str containing * embedded line breaks * text outdented to the left margin * no trailing whitespace. It will always be true that (not docstring) or ((not docstring[0].isspace()) and (docstring.
| 80 | |
| 81 | @dc.dataclass(repr=False) |
| 82 | class Function: |
| 83 | """ |
| 84 | Mutable duck type for inspect.Function. |
| 85 | |
| 86 | docstring - a str containing |
| 87 | * embedded line breaks |
| 88 | * text outdented to the left margin |
| 89 | * no trailing whitespace. |
| 90 | It will always be true that |
| 91 | (not docstring) or ((not docstring[0].isspace()) and (docstring.rstrip() == docstring)) |
| 92 | """ |
| 93 | parameters: ParamDict = dc.field(default_factory=dict) |
| 94 | _: dc.KW_ONLY |
| 95 | name: str |
| 96 | module: Module | Clinic |
| 97 | cls: Class | None |
| 98 | c_basename: str |
| 99 | full_name: str |
| 100 | return_converter: CReturnConverter |
| 101 | kind: FunctionKind |
| 102 | coexist: bool |
| 103 | return_annotation: object = inspect.Signature.empty |
| 104 | docstring: str = '' |
| 105 | # docstring_only means "don't generate a machine-readable |
| 106 | # signature, just a normal docstring". it's True for |
| 107 | # functions with optional groups because we can't represent |
| 108 | # those accurately with inspect.Signature in 3.4. |
| 109 | docstring_only: bool = False |
| 110 | forced_text_signature: str | None = None |
| 111 | critical_section: bool = False |
| 112 | disable_fastcall: bool = False |
| 113 | target_critical_section: list[str] = dc.field(default_factory=list) |
| 114 | |
| 115 | def __post_init__(self) -> None: |
| 116 | self.parent = self.cls or self.module |
| 117 | self.self_converter: self_converter | None = None |
| 118 | self.__render_parameters__: list[Parameter] | None = None |
| 119 | |
| 120 | @functools.cached_property |
| 121 | def displayname(self) -> str: |
| 122 | """Pretty-printable name.""" |
| 123 | if self.kind.new_or_init: |
| 124 | assert isinstance(self.cls, Class) |
| 125 | return self.cls.name |
| 126 | else: |
| 127 | return self.name |
| 128 | |
| 129 | @functools.cached_property |
| 130 | def fulldisplayname(self) -> str: |
| 131 | parent: Class | Module | Clinic | None |
| 132 | if self.kind.new_or_init: |
| 133 | parent = getattr(self.cls, "parent", None) |
| 134 | else: |
| 135 | parent = self.parent |
| 136 | name = self.displayname |
| 137 | while isinstance(parent, (Module, Class)): |
| 138 | name = f"{parent.name}.{name}" |
| 139 | parent = parent.parent |
searching dependent graphs…