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

Method visit_as_pattern

mypy/checkpattern.py:137–152  ·  view source on GitHub ↗
(self, o: AsPattern)

Source from the content-addressed store, hash-verified

135 return result
136
137 def visit_as_pattern(self, o: AsPattern) -> PatternType:
138 current_type = self.type_context[-1]
139 if o.pattern is not None:
140 pattern_type = self.accept(o.pattern, current_type)
141 typ, rest_type, type_map = pattern_type
142 else:
143 typ, rest_type, type_map = current_type, UninhabitedType(), {}
144
145 if not is_uninhabited(typ) and o.name is not None:
146 typ, _ = self.chk.conditional_types_with_intersection(
147 current_type, [get_type_range(typ)], o, default=current_type
148 )
149 if not is_uninhabited(typ):
150 type_map[o.name] = typ
151
152 return PatternType(typ, rest_type, type_map)
153
154 def visit_or_pattern(self, o: OrPattern) -> PatternType:
155 current_type = self.type_context[-1]

Callers

nothing calls this directly

Calls 6

acceptMethod · 0.95
UninhabitedTypeClass · 0.90
is_uninhabitedFunction · 0.85
get_type_rangeFunction · 0.85
PatternTypeClass · 0.85

Tested by

no test coverage detected