From: Mike Bayer Date: Fri, 10 Sep 2021 13:42:11 +0000 (-0400) Subject: document placement of declarative init method X-Git-Tag: rel_1_4_24~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d4367602a05249232d49dbfd47b4a51ddac3beb;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git document placement of declarative init method Fixes: #7013 Fixes: #7015 Change-Id: Iba7eb8aeb37cec08e1bd1edcf28e05b02004afe7 --- 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.