(
stub: nodes.TypeInfo, runtime: type[object], object_path: list[str]
)
| 548 | |
| 549 | |
| 550 | def _verify_disjoint_base( |
| 551 | stub: nodes.TypeInfo, runtime: type[object], object_path: list[str] |
| 552 | ) -> Iterator[Error]: |
| 553 | is_disjoint_runtime = _is_disjoint_base(runtime) |
| 554 | # Don't complain about missing @disjoint_base if there are __slots__, because |
| 555 | # in that case we can infer that it's a disjoint base. |
| 556 | if ( |
| 557 | is_disjoint_runtime |
| 558 | and not stub.is_disjoint_base |
| 559 | and not runtime.__dict__.get("__slots__") |
| 560 | and not stub.is_final |
| 561 | and not (stub.is_enum and stub.enum_members) |
| 562 | ): |
| 563 | yield Error( |
| 564 | object_path, |
| 565 | "is a disjoint base at runtime, but isn't marked with @disjoint_base in the stub", |
| 566 | stub, |
| 567 | runtime, |
| 568 | stub_desc=repr(stub), |
| 569 | ) |
| 570 | elif stub.is_disjoint_base: |
| 571 | if not is_disjoint_runtime: |
| 572 | yield Error( |
| 573 | object_path, |
| 574 | "is marked with @disjoint_base in the stub, but isn't a disjoint base at runtime", |
| 575 | stub, |
| 576 | runtime, |
| 577 | stub_desc=repr(stub), |
| 578 | ) |
| 579 | if runtime.__dict__.get("__slots__"): |
| 580 | yield Error( |
| 581 | object_path, |
| 582 | "is marked as @disjoint_base, but also has slots; add __slots__ instead", |
| 583 | stub, |
| 584 | runtime, |
| 585 | stub_desc=repr(stub), |
| 586 | ) |
| 587 | elif stub.is_final: |
| 588 | yield Error( |
| 589 | object_path, |
| 590 | "is marked as @disjoint_base, but also marked as @final; remove @disjoint_base", |
| 591 | stub, |
| 592 | runtime, |
| 593 | stub_desc=repr(stub), |
| 594 | ) |
| 595 | elif stub.is_enum and stub.enum_members: |
| 596 | yield Error( |
| 597 | object_path, |
| 598 | "is marked as @disjoint_base, but is an enum with members, which is implicitly final; " |
| 599 | "remove @disjoint_base", |
| 600 | stub, |
| 601 | runtime, |
| 602 | stub_desc=repr(stub), |
| 603 | ) |
| 604 | |
| 605 | |
| 606 | def _verify_metaclass( |
no test coverage detected
searching dependent graphs…