Context manager for performing error analysis that should not affect the main SemanticAnalyzer state. Upon entering this context, `self.errors` will start empty. Within this context, you can analyze expressions for errors. Upon exiting this context, the orig
(self)
| 8174 | |
| 8175 | @contextmanager |
| 8176 | def isolated_error_analysis(self) -> Iterator[None]: |
| 8177 | """ |
| 8178 | Context manager for performing error analysis that should not |
| 8179 | affect the main SemanticAnalyzer state. |
| 8180 | |
| 8181 | Upon entering this context, `self.errors` will start empty. |
| 8182 | Within this context, you can analyze expressions for errors. |
| 8183 | Upon exiting this context, the original `self.errors` will be restored, |
| 8184 | and any errors collected during the analysis will be discarded. |
| 8185 | """ |
| 8186 | # Save state |
| 8187 | original_errors = self.errors |
| 8188 | original_num_incomplete_refs = self.num_incomplete_refs |
| 8189 | original_progress = self.progress |
| 8190 | original_deferred = self.deferred |
| 8191 | original_deferral_debug_context_len = len(self.deferral_debug_context) |
| 8192 | |
| 8193 | self.errors = Errors(Options()) |
| 8194 | try: |
| 8195 | yield |
| 8196 | finally: |
| 8197 | # Restore state |
| 8198 | self.errors = original_errors |
| 8199 | self.num_incomplete_refs = original_num_incomplete_refs |
| 8200 | self.progress = original_progress |
| 8201 | self.deferred = original_deferred |
| 8202 | del self.deferral_debug_context[original_deferral_debug_context_len:] |
| 8203 | |
| 8204 | |
| 8205 | def replace_implicit_first_type(sig: FunctionLike, new: Type) -> FunctionLike: |
no test coverage detected