MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _check_not_declarative

Function _check_not_declarative

lib/sqlalchemy/orm/decl_api.py:981–993  ·  view source on GitHub ↗
(cls: Type[Any], base: Type[Any])

Source from the content-addressed store, hash-verified

979
980
981def _check_not_declarative(cls: Type[Any], base: Type[Any]) -> None:
982 cls_dict = cls.__dict__
983 if (
984 "__table__" in cls_dict
985 and not (
986 callable(cls_dict["__table__"])
987 or hasattr(cls_dict["__table__"], "__get__")
988 )
989 ) or isinstance(cls_dict.get("__tablename__", None), str):
990 raise exc.InvalidRequestError(
991 f"Cannot use {base.__name__!r} directly as a declarative base "
992 "class. Create a Base by creating a subclass of it."
993 )
994
995
996class DeclarativeBaseNoMeta(

Callers 2

__init_subclass__Method · 0.85
__init_subclass__Method · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected