From 7d4367602a05249232d49dbfd47b4a51ddac3beb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 10 Sep 2021 09:42:11 -0400 Subject: [PATCH] document placement of declarative init method Fixes: #7013 Fixes: #7015 Change-Id: Iba7eb8aeb37cec08e1bd1edcf28e05b02004afe7 --- doc/build/orm/mapping_styles.rst | 2 ++ lib/sqlalchemy/orm/decl_api.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/build/orm/mapping_styles.rst b/doc/build/orm/mapping_styles.rst index 31f5abdf3c..e643cfce63 100644 --- a/doc/build/orm/mapping_styles.rst +++ b/doc/build/orm/mapping_styles.rst @@ -131,6 +131,8 @@ be produced in a fully explicit fashion using the registry = mapper_registry metadata = mapper_registry.metadata + __init__ = mapper_registry.constructor + The above ``Base`` is equivalent to one created using the :meth:`_orm.registry.generate_base` method and will be fully understood by type analysis tools without the use of plugins. diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py index 23b89a5434..1b35f07286 100644 --- a/lib/sqlalchemy/orm/decl_api.py +++ b/lib/sqlalchemy/orm/decl_api.py @@ -761,6 +761,8 @@ class registry(object): registry = mapper_registry metadata = mapper_registry.metadata + __init__ = mapper_registry.constructor + The :meth:`_orm.registry.generate_base` method provides the implementation for the :func:`_orm.declarative_base` function, which creates the :class:`_orm.registry` and base class all at once. -- 2.47.2