summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-08-31 11:46:55 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-10 17:53:53 -0400
commit450f5c0d6519a439f4025c3892fe4cf3ee2d892c (patch)
tree1f3f2467306304a5e9ccb25f10bfdf9989327ae2 /lib/sqlalchemy/util
parent96bb6dc56d1da2b4fa30afd08ac4dfa665752913 (diff)
downloadsqlalchemy-450f5c0d6519a439f4025c3892fe4cf3ee2d892c.tar.gz
Build out new declarative systems; deprecate mapper()
The ORM Declarative system is now unified into the ORM itself, with new import spaces under ``sqlalchemy.orm`` and new kinds of mappings. Support for decorator-based mappings without using a base class, support for classical style-mapper() calls that have access to the declarative class registry for relationships, and full integration of Declarative with 3rd party class attribute systems like ``dataclasses`` and ``attrs`` is now supported. Fixes: #5508 Change-Id: I130b2b6edff6450bfe8a3e6baa099ff04b5471ff
Diffstat (limited to 'lib/sqlalchemy/util')
-rw-r--r--lib/sqlalchemy/util/__init__.py1
-rw-r--r--lib/sqlalchemy/util/deprecations.py21
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py
index 1d92084cc..5fdcdf654 100644
--- a/lib/sqlalchemy/util/__init__.py
+++ b/lib/sqlalchemy/util/__init__.py
@@ -101,6 +101,7 @@ from .deprecations import deprecated_20_cls # noqa
from .deprecations import deprecated_cls # noqa
from .deprecations import deprecated_params # noqa
from .deprecations import inject_docstring_text # noqa
+from .deprecations import moved_20 # noqa
from .deprecations import SQLALCHEMY_WARN_20 # noqa
from .deprecations import warn_deprecated # noqa
from .deprecations import warn_deprecated_20 # noqa
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py
index 0a79344c5..eae4be768 100644
--- a/lib/sqlalchemy/util/deprecations.py
+++ b/lib/sqlalchemy/util/deprecations.py
@@ -27,10 +27,12 @@ if os.getenv("SQLALCHEMY_WARN_20", "false").lower() in ("true", "yes", "1"):
def _warn_with_version(msg, version, type_, stacklevel):
- if type_ is exc.RemovedIn20Warning and not SQLALCHEMY_WARN_20:
+ is_20 = issubclass(type_, exc.RemovedIn20Warning)
+
+ if is_20 and not SQLALCHEMY_WARN_20:
return
- if type_ is exc.RemovedIn20Warning:
+ if is_20:
msg += " (Background on SQLAlchemy 2.0 at: http://sqlalche.me/e/b8d9)"
warn = type_(msg)
@@ -150,6 +152,12 @@ def deprecated(
return decorate
+def moved_20(message, **kw):
+ return deprecated(
+ "2.0", message=message, warning=exc.MovedIn20Warning, **kw
+ )
+
+
def deprecated_20(api_name, alternative=None, **kw):
message = (
"The %s function/method is considered legacy as of the "
@@ -325,19 +333,14 @@ def _decorate_with_warning(
" (Background on SQLAlchemy 2.0 at: "
":ref:`migration_20_toplevel`)"
)
- warning_only = (
- " (Background on SQLAlchemy 2.0 at: http://sqlalche.me/e/b8d9)"
- )
else:
- doc_only = warning_only = ""
+ doc_only = ""
@decorator
def warned(fn, *args, **kwargs):
skip_warning = kwargs.pop("_sa_skip_warning", False)
if not skip_warning:
- _warn_with_version(
- message + warning_only, version, wtype, stacklevel=3
- )
+ _warn_with_version(message, version, wtype, stacklevel=3)
return fn(*args, **kwargs)
doc = func.__doc__ is not None and func.__doc__ or ""