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

Method expand_type

mypy/plugins/dataclasses.py:161–171  ·  view source on GitHub ↗
(self, current_info: TypeInfo)

Source from the content-addressed store, hash-verified

159 )
160
161 def expand_type(self, current_info: TypeInfo) -> Type | None:
162 if self.type is not None and self.info.self_type is not None:
163 # In general, it is not safe to call `expand_type()` during semantic analysis,
164 # however this plugin is called very late, so all types should be fully ready.
165 # Also, it is tricky to avoid eager expansion of Self types here (e.g. because
166 # we serialize attributes).
167 with state.strict_optional_set(self._api.options.strict_optional):
168 return expand_type(
169 self.type, {self.info.self_type.id: fill_typevars(current_info)}
170 )
171 return self.type
172
173 def to_var(self, current_info: TypeInfo) -> Var:
174 return Var(self.alias or self.name, self.expand_type(current_info))

Callers 3

to_argumentMethod · 0.95
to_varMethod · 0.95
assert_expandMethod · 0.80

Calls 3

expand_typeFunction · 0.90
fill_typevarsFunction · 0.90
strict_optional_setMethod · 0.80

Tested by 1

assert_expandMethod · 0.64