Apply class plugin hooks within a SCC. We run these after to the main semantic analysis so that the hooks don't need to deal with incomplete definitions such as placeholder types. Note that some hooks incorrectly run during the main semantic analysis pass, for historical reason
(graph: Graph, scc: list[str], errors: Errors)
| 442 | |
| 443 | |
| 444 | def apply_class_plugin_hooks(graph: Graph, scc: list[str], errors: Errors) -> None: |
| 445 | """Apply class plugin hooks within a SCC. |
| 446 | |
| 447 | We run these after to the main semantic analysis so that the hooks |
| 448 | don't need to deal with incomplete definitions such as placeholder |
| 449 | types. |
| 450 | |
| 451 | Note that some hooks incorrectly run during the main semantic |
| 452 | analysis pass, for historical reasons. |
| 453 | """ |
| 454 | num_passes = 0 |
| 455 | incomplete = True |
| 456 | # If we encounter a base class that has not been processed, we'll run another |
| 457 | # pass. This should eventually reach a fixed point. |
| 458 | while incomplete: |
| 459 | assert num_passes < 10, "Internal error: too many class plugin hook passes" |
| 460 | num_passes += 1 |
| 461 | incomplete = False |
| 462 | for module in scc: |
| 463 | state = graph[module] |
| 464 | tree = state.tree |
| 465 | assert tree |
| 466 | with state.wrap_context(): |
| 467 | for _, node, _ in tree.local_definitions(): |
| 468 | if isinstance(node.node, TypeInfo): |
| 469 | if not apply_hooks_to_class( |
| 470 | state.manager.semantic_analyzer, |
| 471 | module, |
| 472 | node.node, |
| 473 | state.options, |
| 474 | tree, |
| 475 | errors, |
| 476 | ): |
| 477 | incomplete = True |
| 478 | |
| 479 | |
| 480 | def apply_hooks_to_class( |
no test coverage detected
searching dependent graphs…