MCPcopy Create free account
hub / github.com/python/mypy / maybe_inspect

Method maybe_inspect

mypy/test/testfinegrained.py:328–359  ·  view source on GitHub ↗
(self, step: int, server: Server, src: str)

Source from the content-addressed store, hash-verified

326 return normalize_messages(output)
327
328 def maybe_inspect(self, step: int, server: Server, src: str) -> list[str]:
329 output: list[str] = []
330 targets = self.get_inspect(src, step)
331 for flags, location in targets:
332 m = re.match(r"--show=(\w+)", flags)
333 show = m.group(1) if m else "type"
334 verbosity = 0
335 if "-v" in flags:
336 verbosity = 1
337 if "-vv" in flags:
338 verbosity = 2
339 m = re.match(r"--limit=([0-9]+)", flags)
340 limit = int(m.group(1)) if m else 0
341 include_span = "--include-span" in flags
342 include_kind = "--include-kind" in flags
343 include_object_attrs = "--include-object-attrs" in flags
344 union_attrs = "--union-attrs" in flags
345 force_reload = "--force-reload" in flags
346 res: dict[str, Any] = server.cmd_inspect(
347 show,
348 location,
349 verbosity=verbosity,
350 limit=limit,
351 include_span=include_span,
352 include_kind=include_kind,
353 include_object_attrs=include_object_attrs,
354 union_attrs=union_attrs,
355 force_reload=force_reload,
356 )
357 val = res["error"] if "error" in res else res["out"] + res["err"]
358 output.extend(val.strip().split("\n"))
359 return output
360
361 def get_suggest(self, program_text: str, incremental_step: int) -> list[tuple[str, str]]:
362 step_bit = "1?" if incremental_step == 1 else str(incremental_step)

Callers 2

run_caseMethod · 0.95
perform_stepMethod · 0.95

Calls 7

get_inspectMethod · 0.95
intClass · 0.85
groupMethod · 0.80
cmd_inspectMethod · 0.80
extendMethod · 0.80
splitMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected