MCPcopy
hub / github.com/python/mypy / try_type

Method try_type

mypy/suggestions.py:686–704  ·  view source on GitHub ↗

Recheck a function while assuming it has type typ. Return all error messages.

(self, func: FuncDef, typ: ProperType)

Source from the content-addressed store, hash-verified

684 return node.func
685
686 def try_type(self, func: FuncDef, typ: ProperType) -> list[str]:
687 """Recheck a function while assuming it has type typ.
688
689 Return all error messages.
690 """
691 old = func.unanalyzed_type
692 # During reprocessing, unanalyzed_type gets copied to type (by aststrip).
693 # We set type to None to ensure that the type always changes during
694 # reprocessing.
695 func.type = None
696 func.unanalyzed_type = typ
697 try:
698 res = self.fgmanager.trigger(func.fullname)
699 # if res:
700 # print('===', typ)
701 # print('\n'.join(res))
702 return res
703 finally:
704 func.unanalyzed_type = old
705
706 def reload(self, state: State) -> list[str]:
707 """Recheck the module given by state."""

Callers 3

get_callsitesMethod · 0.95
find_bestMethod · 0.95
get_suggestionMethod · 0.95

Calls 1

triggerMethod · 0.80

Tested by

no test coverage detected