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

Method expr_type

mypy/inspections.py:229–242  ·  view source on GitHub ↗

Format type for an expression using current options. If type is known, second item returned is True. If type is not known, an error message is returned instead, and second item returned is False.

(self, expression: Expression)

Source from the content-addressed store, hash-verified

227 self.fg_manager.manager.options.export_types = old
228
229 def expr_type(self, expression: Expression) -> tuple[str, bool]:
230 """Format type for an expression using current options.
231
232 If type is known, second item returned is True. If type is not known, an error
233 message is returned instead, and second item returned is False.
234 """
235 expr_type = self.fg_manager.manager.all_types.get(expression)
236 if expr_type is None:
237 return self.missing_type(expression), False
238
239 type_str = format_type(
240 expr_type, self.fg_manager.manager.options, verbosity=self.verbosity
241 )
242 return self.add_prefixes(type_str, expression), True
243
244 def object_type(self) -> Instance:
245 builtins = self.fg_manager.graph["builtins"].tree

Callers

nothing calls this directly

Calls 4

missing_typeMethod · 0.95
add_prefixesMethod · 0.95
format_typeFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected