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

Method record_callable_target_precision

mypy/stats.py:273–296  ·  view source on GitHub ↗

Record imprecision caused by callee argument types. This only considers arguments passed in a call expression. Arguments with default values that aren't provided in a call arguably don't contribute to typing imprecision at the *call site* (but they contribute at the

(self, o: CallExpr, callee: CallableType)

Source from the content-addressed store, hash-verified

271 pass # TODO: Handle overloaded functions, etc.
272
273 def record_callable_target_precision(self, o: CallExpr, callee: CallableType) -> None:
274 """Record imprecision caused by callee argument types.
275
276 This only considers arguments passed in a call expression. Arguments
277 with default values that aren't provided in a call arguably don't
278 contribute to typing imprecision at the *call site* (but they
279 contribute at the function definition).
280 """
281 assert self.typemap
282 typemap = self.typemap
283 actual_to_formal = map_formals_to_actuals(
284 o.arg_kinds,
285 o.arg_names,
286 callee.arg_kinds,
287 callee.arg_names,
288 lambda n: typemap[o.args[n]],
289 )
290 for formals in actual_to_formal:
291 for n in formals:
292 formal = get_proper_type(callee.arg_types[n])
293 if isinstance(formal, AnyType):
294 self.record_line(o.line, TYPE_ANY)
295 elif is_imprecise(formal):
296 self.record_line(o.line, TYPE_IMPRECISE)
297
298 def visit_member_expr(self, o: MemberExpr) -> None:
299 self.process_node(o)

Callers 1

Calls 5

record_lineMethod · 0.95
map_formals_to_actualsFunction · 0.90
get_proper_typeFunction · 0.90
isinstanceFunction · 0.85
is_impreciseFunction · 0.85

Tested by

no test coverage detected