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

Method visit_Dict

mypy/fastparse.py:2134–2148  ·  view source on GitHub ↗
(self, n: ast3.Dict)

Source from the content-addressed store, hash-verified

2132 )
2133
2134 def visit_Dict(self, n: ast3.Dict) -> Type:
2135 if not n.keys:
2136 return self.invalid_type(n)
2137 items: dict[str, Type] = {}
2138 extra_items_from = []
2139 for item_name, value in zip(n.keys, n.values):
2140 if not isinstance(item_name, ast3.Constant) or not isinstance(item_name.value, str):
2141 if item_name is None:
2142 extra_items_from.append(self.visit(value))
2143 continue
2144 return self.invalid_type(n)
2145 items[item_name.value] = self.visit(value)
2146 result = TypedDictType(items, set(), set(), _dummy_fallback, n.lineno, n.col_offset)
2147 result.extra_items_from = extra_items_from
2148 return result
2149
2150 # Attribute(expr value, identifier attr, expr_context ctx)
2151 def visit_Attribute(self, n: Attribute) -> Type:

Callers

nothing calls this directly

Calls 7

invalid_typeMethod · 0.95
visitMethod · 0.95
TypedDictTypeClass · 0.90
zipFunction · 0.85
isinstanceFunction · 0.85
setClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected