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

Function add_method

mypy/plugins/common.py:189–213  ·  view source on GitHub ↗

Adds a new method to a class. Deprecated, use add_method_to_class() instead.

(
    ctx: ClassDefContext,
    name: str,
    args: list[Argument],
    return_type: Type,
    self_type: Type | None = None,
    tvar_def: TypeVarType | None = None,
    is_classmethod: bool = False,
    is_staticmethod: bool = False,
)

Source from the content-addressed store, hash-verified

187
188
189def add_method(
190 ctx: ClassDefContext,
191 name: str,
192 args: list[Argument],
193 return_type: Type,
194 self_type: Type | None = None,
195 tvar_def: TypeVarType | None = None,
196 is_classmethod: bool = False,
197 is_staticmethod: bool = False,
198) -> None:
199 """
200 Adds a new method to a class.
201 Deprecated, use add_method_to_class() instead.
202 """
203 add_method_to_class(
204 ctx.api,
205 ctx.cls,
206 name=name,
207 args=args,
208 return_type=return_type,
209 self_type=self_type,
210 tvar_def=tvar_def,
211 is_classmethod=is_classmethod,
212 is_staticmethod=is_staticmethod,
213 )
214
215
216class MethodSpec(NamedTuple):

Callers 3

add_extra_methods_hookFunction · 0.90
add_extra_methods_hookFunction · 0.90

Calls 1

add_method_to_classFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…