(cls: Type[Any])
| 532 | |
| 533 | |
| 534 | def _setup_declarative_base(cls: Type[Any]) -> None: |
| 535 | metadata = getattr(cls, "metadata", None) |
| 536 | type_annotation_map = getattr(cls, "type_annotation_map", None) |
| 537 | reg = getattr(cls, "registry", None) |
| 538 | |
| 539 | if reg is not None: |
| 540 | if not isinstance(reg, registry): |
| 541 | raise exc.InvalidRequestError( |
| 542 | "Declarative base class has a 'registry' attribute that is " |
| 543 | "not an instance of sqlalchemy.orm.registry()" |
| 544 | ) |
| 545 | elif type_annotation_map is not None: |
| 546 | raise exc.InvalidRequestError( |
| 547 | "Declarative base class has both a 'registry' attribute and a " |
| 548 | "type_annotation_map entry. Per-base type_annotation_maps " |
| 549 | "are not supported. Please apply the type_annotation_map " |
| 550 | "to this registry directly." |
| 551 | ) |
| 552 | |
| 553 | else: |
| 554 | reg = registry( |
| 555 | metadata=metadata, type_annotation_map=type_annotation_map |
| 556 | ) |
| 557 | cls.registry = reg |
| 558 | |
| 559 | cls._sa_registry = reg |
| 560 | |
| 561 | if "metadata" not in cls.__dict__: |
| 562 | cls.metadata = cls.registry.metadata |
| 563 | |
| 564 | if getattr(cls, "__init__", object.__init__) is object.__init__: |
| 565 | cls.__init__ = cls.registry.constructor |
| 566 | |
| 567 | |
| 568 | def _generate_dc_transforms( |
no test coverage detected