summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-01-15 13:11:38 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-01-15 13:11:38 -0500
commit6da2f72b1144738ddae23e7fd882a8cd79ea1c60 (patch)
tree857432f3affaf0d81c346fc46fc8aafe44d9035e /lib/sqlalchemy/orm
parent48eed9eb9c6ba853b48e41ef6038ec97c5a3fb68 (diff)
downloadsqlalchemy-6da2f72b1144738ddae23e7fd882a8cd79ea1c60.tar.gz
super-fine pass through the metadata tutorial
try to keep the wordiness down here, using sidebars and topics for non-essential information. Sphinx seems to read out attrs from under TYPE_CHECKING sections now so link out the attrs in DeclarativeBase w/ docstrings, not sure why we didn't think of this earlier. looks great Change-Id: Ib2e07e3606185998561c2d77b2564fd3eddb4d75
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/decl_api.py124
1 files changed, 122 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py
index b65f55618..844628443 100644
--- a/lib/sqlalchemy/orm/decl_api.py
+++ b/lib/sqlalchemy/orm/decl_api.py
@@ -681,19 +681,77 @@ class DeclarativeBase(
"""
if typing.TYPE_CHECKING:
- registry: ClassVar[_RegistryType]
_sa_registry: ClassVar[_RegistryType]
+
+ registry: ClassVar[_RegistryType]
+ """Refers to the :class:`_orm.registry` in use where new
+ :class:`_orm.Mapper` objects will be associated."""
+
metadata: ClassVar[MetaData]
+ """Refers to the :class:`_schema.MetaData` collection that will be used
+ for new :class:`_schema.Table` objects.
+
+ .. seealso::
+
+ :ref:`orm_declarative_metadata`
+
+ """
__name__: ClassVar[str]
+
__mapper__: ClassVar[Mapper[Any]]
+ """The :class:`_orm.Mapper` object to which a particular class is
+ mapped.
+
+ May also be acquired using :func:`_sa.inspect`, e.g.
+ ``inspect(klass)``.
+
+ """
+
__table__: ClassVar[FromClause]
+ """The :class:`_schema.Table` to which a particular subclass is
+ mapped.
+
+ .. seealso::
+
+ :ref:`orm_declarative_metadata`
+
+ """
# pyright/pylance do not consider a classmethod a ClassVar so use Any
# https://github.com/microsoft/pylance-release/issues/3484
__tablename__: Any
+ """String name to assign to the generated
+ :class:`_schema.Table` object, if not specified directly via
+ :attr:`_orm.DeclarativeBase.__table__`.
+
+ .. seealso::
+
+ :ref:`orm_declarative_table`
+
+ """
+
__mapper_args__: Any
+ """Dictionary of arguments which will be passed to the
+ :class:`_orm.Mapper` constructor.
+
+ .. seealso::
+
+ :ref:`orm_declarative_mapper_options`
+
+ """
+
__table_args__: Any
+ """A dictionary or tuple of arguments that will be passed to the
+ :class:`_schema.Table` constructor. See
+ :ref:`orm_declarative_table_configuration`
+ for background on the specific structure of this collection.
+
+ .. seealso::
+
+ :ref:`orm_declarative_table_configuration`
+
+ """
def __init__(self, **kw: Any):
...
@@ -734,14 +792,76 @@ class DeclarativeBaseNoMeta(inspection.Inspectable[Mapper[Any]]):
"""
- registry: ClassVar[_RegistryType]
_sa_registry: ClassVar[_RegistryType]
+
+ registry: ClassVar[_RegistryType]
+ """Refers to the :class:`_orm.registry` in use where new
+ :class:`_orm.Mapper` objects will be associated."""
+
metadata: ClassVar[MetaData]
+ """Refers to the :class:`_schema.MetaData` collection that will be used
+ for new :class:`_schema.Table` objects.
+
+ .. seealso::
+
+ :ref:`orm_declarative_metadata`
+
+ """
+
__mapper__: ClassVar[Mapper[Any]]
+ """The :class:`_orm.Mapper` object to which a particular class is
+ mapped.
+
+ May also be acquired using :func:`_sa.inspect`, e.g.
+ ``inspect(klass)``.
+
+ """
+
__table__: Optional[FromClause]
+ """The :class:`_schema.Table` to which a particular subclass is
+ mapped.
+
+ .. seealso::
+
+ :ref:`orm_declarative_metadata`
+
+ """
if typing.TYPE_CHECKING:
+ __tablename__: Any
+ """String name to assign to the generated
+ :class:`_schema.Table` object, if not specified directly via
+ :attr:`_orm.DeclarativeBase.__table__`.
+
+ .. seealso::
+
+ :ref:`orm_declarative_table`
+
+ """
+
+ __mapper_args__: Any
+ """Dictionary of arguments which will be passed to the
+ :class:`_orm.Mapper` constructor.
+
+ .. seealso::
+
+ :ref:`orm_declarative_mapper_options`
+
+ """
+
+ __table_args__: Any
+ """A dictionary or tuple of arguments that will be passed to the
+ :class:`_schema.Table` constructor. See
+ :ref:`orm_declarative_table_configuration`
+ for background on the specific structure of this collection.
+
+ .. seealso::
+
+ :ref:`orm_declarative_table_configuration`
+
+ """
+
def __init__(self, **kw: Any):
...