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

Method cmd_inspect

mypy/dmypy_server.py:935–979  ·  view source on GitHub ↗

Locate and inspect expression(s).

(
        self,
        show: str,
        location: str,
        verbosity: int = 0,
        limit: int = 0,
        include_span: bool = False,
        include_kind: bool = False,
        include_object_attrs: bool = False,
        union_attrs: bool = False,
        force_reload: bool = False,
    )

Source from the content-addressed store, hash-verified

933 )
934
935 def cmd_inspect(
936 self,
937 show: str,
938 location: str,
939 verbosity: int = 0,
940 limit: int = 0,
941 include_span: bool = False,
942 include_kind: bool = False,
943 include_object_attrs: bool = False,
944 union_attrs: bool = False,
945 force_reload: bool = False,
946 ) -> dict[str, object]:
947 """Locate and inspect expression(s)."""
948 if not self.fine_grained_manager:
949 return {
950 "error": 'Command "inspect" is only valid after a "check" command'
951 " (that produces no parse errors)"
952 }
953 engine = InspectionEngine(
954 self.fine_grained_manager,
955 verbosity=verbosity,
956 limit=limit,
957 include_span=include_span,
958 include_kind=include_kind,
959 include_object_attrs=include_object_attrs,
960 union_attrs=union_attrs,
961 force_reload=force_reload,
962 )
963 old_inspections = self.options.inspections
964 self.options.inspections = True
965 try:
966 if show == "type":
967 result = engine.get_type(location)
968 elif show == "attrs":
969 result = engine.get_attrs(location)
970 elif show == "definition":
971 result = engine.get_definition(location)
972 else:
973 assert False, "Unknown inspection kind"
974 finally:
975 self.options.inspections = old_inspections
976 if "out" in result:
977 assert isinstance(result["out"], str)
978 result["out"] += "\n"
979 return result
980
981 def cmd_suggest(self, function: str, callsites: bool, **kwargs: Any) -> dict[str, object]:
982 """Suggest a signature for a function."""

Callers 1

maybe_inspectMethod · 0.80

Calls 5

get_typeMethod · 0.95
get_attrsMethod · 0.95
get_definitionMethod · 0.95
InspectionEngineClass · 0.90
isinstanceFunction · 0.85

Tested by 1

maybe_inspectMethod · 0.64