Temporarily change the error import context to match this state. Also report an internal error if an unexpected exception was raised and raise an exception on a blocking error, unless check_blockers is False. Skipping blocking error reporting is used in the semantic
(self, check_blockers: bool = True)
| 3062 | |
| 3063 | @contextlib.contextmanager |
| 3064 | def wrap_context(self, check_blockers: bool = True) -> Iterator[None]: |
| 3065 | """Temporarily change the error import context to match this state. |
| 3066 | |
| 3067 | Also report an internal error if an unexpected exception was raised |
| 3068 | and raise an exception on a blocking error, unless |
| 3069 | check_blockers is False. Skipping blocking error reporting is used |
| 3070 | in the semantic analyzer so that we can report all blocking errors |
| 3071 | for a file (across multiple targets) to maintain backward |
| 3072 | compatibility. |
| 3073 | """ |
| 3074 | save_import_context = self.manager.errors.import_context() |
| 3075 | self.manager.errors.set_import_context(self.import_context) |
| 3076 | try: |
| 3077 | yield |
| 3078 | except CompileError: |
| 3079 | raise |
| 3080 | except Exception as err: |
| 3081 | report_internal_error( |
| 3082 | err, |
| 3083 | self.path, |
| 3084 | 0, |
| 3085 | self.manager.errors, |
| 3086 | self.options, |
| 3087 | self.manager.stdout, |
| 3088 | self.manager.stderr, |
| 3089 | ) |
| 3090 | self.manager.errors.set_import_context(save_import_context) |
| 3091 | # TODO: Move this away once we've removed the old semantic analyzer? |
| 3092 | if check_blockers: |
| 3093 | self.check_blockers() |
| 3094 | |
| 3095 | def load_fine_grained_deps(self) -> dict[str, set[str]]: |
| 3096 | return self.manager.load_fine_grained_deps(self.id) |
no test coverage detected