From 01c50c64e302c193733cef7fb146fbab8eaa44bd Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 3 Jan 2022 13:49:26 -0500 Subject: 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 --- lib/sqlalchemy/ext/declarative/__init__.py | 1 - lib/sqlalchemy/ext/declarative/extensions.py | 19 ------------------- lib/sqlalchemy/ext/mutable.py | 5 ++--- 3 files changed, 2 insertions(+), 23 deletions(-) (limited to 'lib/sqlalchemy/ext') diff --git a/lib/sqlalchemy/ext/declarative/__init__.py b/lib/sqlalchemy/ext/declarative/__init__.py index b1c1d3691..ebb992742 100644 --- a/lib/sqlalchemy/ext/declarative/__init__.py +++ b/lib/sqlalchemy/ext/declarative/__init__.py @@ -8,7 +8,6 @@ from .extensions import AbstractConcreteBase from .extensions import ConcreteBase from .extensions import DeferredReflection -from .extensions import instrument_declarative from ... import util from ...orm.decl_api import as_declarative as _as_declarative from ...orm.decl_api import declarative_base as _declarative_base diff --git a/lib/sqlalchemy/ext/declarative/extensions.py b/lib/sqlalchemy/ext/declarative/extensions.py index 1862592f5..b7c0e78d9 100644 --- a/lib/sqlalchemy/ext/declarative/extensions.py +++ b/lib/sqlalchemy/ext/declarative/extensions.py @@ -8,9 +8,7 @@ from ... import inspection -from ... import util from ...orm import exc as orm_exc -from ...orm import registry from ...orm import relationships from ...orm.base import _mapper_or_none from ...orm.clsregistry import _resolver @@ -20,23 +18,6 @@ from ...schema import Table from ...util import OrderedDict -@util.deprecated( - "2.0", - "the instrument_declarative function is deprecated " - "and will be removed in SQLAlhcemy 2.0. Please use " - ":meth:`_orm.registry.map_declaratively", -) -def instrument_declarative(cls, cls_registry, metadata): - """Given a class, configure the class declaratively, - using the given registry, which can be any dictionary, and - MetaData object. - - """ - registry(metadata=metadata, class_registry=cls_registry).map_declaratively( - cls - ) - - class ConcreteBase: """A helper class for 'concrete' declarative mappings. diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 7e277d379..7a497abfc 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -360,7 +360,6 @@ from .. import event from .. import inspect from .. import types from ..orm import Mapper -from ..orm import mapper from ..orm.attributes import flag_modified from ..sql.base import SchemaEventTarget from ..util import memoized_property @@ -567,7 +566,7 @@ class Mutable(MutableBase): if isinstance(prop.columns[0].type, sqltype): cls.associate_with_attribute(getattr(class_, prop.key)) - event.listen(mapper, "mapper_configured", listen_for_type) + event.listen(Mapper, "mapper_configured", listen_for_type) @classmethod def as_mutable(cls, sqltype): @@ -629,7 +628,7 @@ class Mutable(MutableBase): ) or (prop.columns[0].type is sqltype): cls.associate_with_attribute(getattr(class_, prop.key)) - event.listen(mapper, "mapper_configured", listen_for_type) + event.listen(Mapper, "mapper_configured", listen_for_type) return sqltype -- cgit v1.2.1