Report only those `unreachable`, `redundant-expr`, and `redundant-casts` errors that could not be ruled out in any iteration step.
(self)
| 332 | self.revealed_types = defaultdict(list) |
| 333 | |
| 334 | def yield_uselessness_error_infos(self) -> Iterator[tuple[str, Context, ErrorCode]]: |
| 335 | """Report only those `unreachable`, `redundant-expr`, and `redundant-casts` |
| 336 | errors that could not be ruled out in any iteration step.""" |
| 337 | |
| 338 | persistent_uselessness_errors = set() |
| 339 | for candidate in set(chain(*self.uselessness_errors)): |
| 340 | if all( |
| 341 | (candidate in errors) or (candidate[2] in lines) |
| 342 | for errors, lines in zip(self.uselessness_errors, self.unreachable_lines) |
| 343 | ): |
| 344 | persistent_uselessness_errors.add(candidate) |
| 345 | for error_info in persistent_uselessness_errors: |
| 346 | context = Context(line=error_info[2], column=error_info[3]) |
| 347 | context.end_line = error_info[4] |
| 348 | context.end_column = error_info[5] |
| 349 | yield error_info[1], context, error_info[0] |
| 350 | |
| 351 | def yield_nonoverlapping_types( |
| 352 | self, |