MCPcopy
hub / github.com/python/mypy / make_fake_register_class_instance

Function make_fake_register_class_instance

mypy/plugins/singledispatch.py:52–66  ·  view source on GitHub ↗
(
    api: CheckerPluginInterface, type_args: Sequence[Type]
)

Source from the content-addressed store, hash-verified

50
51
52def make_fake_register_class_instance(
53 api: CheckerPluginInterface, type_args: Sequence[Type]
54) -> Instance:
55 defn = ClassDef(SINGLEDISPATCH_REGISTER_RETURN_CLASS, Block([]))
56 defn.fullname = f"functools.{SINGLEDISPATCH_REGISTER_RETURN_CLASS}"
57 info = TypeInfo(SymbolTable(), defn, "functools")
58 obj_type = api.named_generic_type("builtins.object", []).type
59 info.bases = [Instance(obj_type, [])]
60 info.mro = [info, obj_type]
61 defn.info = info
62
63 func_arg = Argument(Var("name"), AnyType(TypeOfAny.implementation_artifact), None, ARG_POS)
64 add_method_to_class(api, defn, "__call__", [func_arg], NoneType())
65
66 return Instance(info, type_args)
67
68
69PluginContext: _TypeAlias = FunctionContext | MethodContext

Callers 1

Calls 11

ClassDefClass · 0.90
BlockClass · 0.90
TypeInfoClass · 0.90
SymbolTableClass · 0.90
InstanceClass · 0.90
ArgumentClass · 0.90
VarClass · 0.90
AnyTypeClass · 0.90
add_method_to_classFunction · 0.90
NoneTypeClass · 0.90
named_generic_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…