MCPcopy Index your code
hub / github.com/python/mypy / FuncDecl

Class FuncDecl

mypyc/ir/func_ir.py:138–256  ·  view source on GitHub ↗

Declaration of a function in IR (without body or implementation). A function can be a regular module-level function, a method, a static method, a class method, or a property getter/setter.

Source from the content-addressed store, hash-verified

136
137
138class FuncDecl:
139 """Declaration of a function in IR (without body or implementation).
140
141 A function can be a regular module-level function, a method, a
142 static method, a class method, or a property getter/setter.
143 """
144
145 def __init__(
146 self,
147 name: str,
148 class_name: str | None,
149 module_name: str,
150 sig: FuncSignature,
151 kind: int = FUNC_NORMAL,
152 *,
153 is_prop_setter: bool = False,
154 is_prop_getter: bool = False,
155 is_generator: bool = False,
156 is_coroutine: bool = False,
157 implicit: bool = False,
158 internal: bool = False,
159 ) -> None:
160 self.name = name
161 self.class_name = class_name
162 self.module_name = module_name
163 self.sig = sig
164 self.kind = kind
165 self.is_prop_setter = is_prop_setter
166 self.is_prop_getter = is_prop_getter
167 self.is_generator = is_generator
168 self.is_coroutine = is_coroutine
169 if class_name is None:
170 self.bound_sig: FuncSignature | None = None
171 else:
172 if kind == FUNC_STATICMETHOD:
173 self.bound_sig = sig
174 else:
175 self.bound_sig = sig.bound_sig()
176
177 # If True, not present in the mypy AST and must be synthesized during irbuild
178 # Currently only supported for property getters/setters
179 self.implicit = implicit
180
181 # If True, only direct C level calls are supported (no wrapper function)
182 self.internal = internal
183
184 # This is optional because this will be set to the line number when the corresponding
185 # FuncIR is created
186 self._line: int | None = None
187
188 @property
189 def line(self) -> int:
190 assert self._line is not None
191 return self._line
192
193 @line.setter
194 def line(self, line: int) -> None:
195 self._line = line

Callers 15

gen_func_irFunction · 0.90
gen_glue_methodFunction · 0.90
gen_glue_propertyFunction · 0.90
gen_glue_property_setterFunction · 0.90
enter_methodMethod · 0.90
allocate_classFunction · 0.90
prepare_func_defFunction · 0.90
prepare_fast_pathFunction · 0.90
add_getter_declarationFunction · 0.90
add_setter_declarationFunction · 0.90

Calls

no outgoing calls

Tested by 5

func_declMethod · 0.72
test_callMethod · 0.72
test_call_two_argsMethod · 0.72
test_simpleMethod · 0.72
test_registerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…