diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-03 13:49:26 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-05 19:28:49 -0500 |
commit | 01c50c64e302c193733cef7fb146fbab8eaa44bd (patch) | |
tree | dca946206da557a14a681768d094b92c95dfabe4 /lib/sqlalchemy/orm/mapper.py | |
parent | 146a349d81023805264f81643db50a5281da90da (diff) | |
download | sqlalchemy-01c50c64e302c193733cef7fb146fbab8eaa44bd.tar.gz |
Remove all remaining removed_in_20 warnings slated for removal
Finalize all remaining removed-in-2.0 changes so that we
can begin doing pep-484 typing without old things
getting in the way (we will also have to do public_factory).
note there are a few "moved_in_20()" and "became_legacy_in_20()"
warnings still in place. The SQLALCHEMY_WARN_20 variable
is now removed.
Also removed here are the legacy "in place mutators" for Select
statements, and some keyword-only argument signatures in Core
have been added.
Also in the big change department, the ORM mapper() function
is removed entirely; the Mapper class is otherwise unchanged,
just the public-facing API function. Mappers are now always
given a registry in which to participate, however the
argument signature of Mapper is not changed. ideally "registry"
would be the first positional argument.
Fixes: #7257
Change-Id: Ic70c57b9f1cf7eb996338af5183b11bdeb3e1623
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 21da7c2f3..bc818559d 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -57,8 +57,6 @@ from ..util import HasMemoized _mapper_registries = weakref.WeakKeyDictionary() -_legacy_registry = None - def _all_registries(): with _CONFIGURE_MUTEX: @@ -148,16 +146,15 @@ class Mapper( ): r"""Direct constructor for a new :class:`_orm.Mapper` object. - The :func:`_orm.mapper` function is normally invoked through the + The :class:`_orm.Mapper` constructor is not called directly, and + is normally invoked through the use of the :class:`_orm.registry` object through either the :ref:`Declarative <orm_declarative_mapping>` or :ref:`Imperative <orm_imperative_mapping>` mapping styles. - .. versionchanged:: 1.4 The :func:`_orm.mapper` function should not - be called directly for classical mapping; for a classical mapping - configuration, use the :meth:`_orm.registry.map_imperatively` - method. The :func:`_orm.mapper` function may become private in a - future release. + .. versionchanged:: 2.0 The public facing ``mapper()`` function is + removed; for a classical mapping configuration, use the + :meth:`_orm.registry.map_imperatively` method. Parameters documented below may be passed to either the :meth:`_orm.registry.map_imperatively` method, or may be passed in the @@ -1202,8 +1199,7 @@ class Mapper( # we expect that declarative has applied the class manager # already and set up a registry. if this is None, - # we will emit a deprecation warning below when we also see that - # it has no registry. + # this raises as of 2.0. manager = attributes.manager_of_class(self.class_) if self.non_primary: @@ -1251,14 +1247,12 @@ class Mapper( ) if not manager.registry: - util.warn_deprecated_20( - "Calling the mapper() function directly outside of a " - "declarative registry is deprecated." + raise sa_exc.InvalidRequestError( + "The _mapper() function may not be invoked directly outside " + "of a declarative registry." " Please use the sqlalchemy.orm.registry.map_imperatively() " "function for a classical mapping." ) - assert _legacy_registry is not None - _legacy_registry._add_manager(manager) self.class_manager = manager self.registry = manager.registry |