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

Method json_suggestion

mypy/suggestions.py:722–742  ·  view source on GitHub ↗

Produce a json blob for a suggestion suitable for application by pyannotate.

(
        self, mod: str, func_name: str, node: FuncDef, suggestion: PyAnnotateSignature
    )

Source from the content-addressed store, hash-verified

720 return self.manager.semantic_analyzer.named_type(s)
721
722 def json_suggestion(
723 self, mod: str, func_name: str, node: FuncDef, suggestion: PyAnnotateSignature
724 ) -> str:
725 """Produce a json blob for a suggestion suitable for application by pyannotate."""
726 # pyannotate irritatingly drops class names for class and static methods
727 if node.is_class or node.is_static:
728 func_name = func_name.split(".", 1)[-1]
729
730 # pyannotate works with either paths relative to where the
731 # module is rooted or with absolute paths. We produce absolute
732 # paths because it is simpler.
733 path = os.path.abspath(self.graph[mod].xpath)
734
735 obj = {
736 "signature": suggestion,
737 "line": node.line,
738 "path": path,
739 "func_name": func_name,
740 "samples": 0,
741 }
742 return json.dumps([obj], sort_keys=True)
743
744 def pyannotate_signature(
745 self, cur_module: str | None, is_method: bool, typ: CallableType

Callers 1

suggestMethod · 0.95

Calls 2

splitMethod · 0.80
dumpsMethod · 0.80

Tested by

no test coverage detected