| 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)) |