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

Function check_post_init

mypy/plugins/dataclasses.py:1110–1131  ·  view source on GitHub ↗
(api: TypeChecker, defn: FuncItem, info: TypeInfo)

Source from the content-addressed store, hash-verified

1108
1109
1110def check_post_init(api: TypeChecker, defn: FuncItem, info: TypeInfo) -> None:
1111 if defn.type is None:
1112 return
1113 assert isinstance(defn.type, FunctionLike)
1114
1115 ideal_sig_method = info.get_method(_INTERNAL_POST_INIT_SYM_NAME)
1116 assert ideal_sig_method is not None and ideal_sig_method.type is not None
1117 ideal_sig = ideal_sig_method.type
1118 assert isinstance(ideal_sig, ProperType) # we set it ourselves
1119 assert isinstance(ideal_sig, CallableType)
1120 ideal_sig = ideal_sig.copy_modified(name="__post_init__")
1121
1122 api.check_override(
1123 override=defn.type,
1124 original=ideal_sig,
1125 name="__post_init__",
1126 name_in_super="__post_init__",
1127 supertype="dataclass",
1128 original_class_or_static=False,
1129 override_class_or_static=False,
1130 node=defn,
1131 )

Callers

nothing calls this directly

Calls 4

isinstanceFunction · 0.85
check_overrideMethod · 0.80
get_methodMethod · 0.45
copy_modifiedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…