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

Method add_method

mypy/plugins/attrs.py:1002–1018  ·  view source on GitHub ↗

Add a method: def (self, ) -> ): ... to info. self_type: The type to use for the self argument or None to use the inferred self type. tvd: If the method is generic these should be the type variables.

(
        self,
        method_name: str,
        args: list[Argument],
        ret_type: Type,
        self_type: Type | None = None,
        tvd: TypeVarType | None = None,
    )

Source from the content-addressed store, hash-verified

1000 self.self_type = fill_typevars(ctx.cls.info)
1001
1002 def add_method(
1003 self,
1004 method_name: str,
1005 args: list[Argument],
1006 ret_type: Type,
1007 self_type: Type | None = None,
1008 tvd: TypeVarType | None = None,
1009 ) -> None:
1010 """Add a method: def <method_name>(self, <args>) -> <ret_type>): ... to info.
1011
1012 self_type: The type to use for the self argument or None to use the inferred self type.
1013 tvd: If the method is generic these should be the type variables.
1014 """
1015 self_type = self_type if self_type is not None else self.self_type
1016 add_method_to_class(
1017 self.ctx.api, self.ctx.cls, method_name, args, ret_type, self_type, tvd
1018 )
1019
1020
1021def _get_attrs_init_type(typ: Instance) -> CallableType | None:

Callers 2

_add_orderFunction · 0.45
_add_initFunction · 0.45

Calls 1

add_method_to_classFunction · 0.90

Tested by

no test coverage detected