summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-05-06 14:25:22 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-05-06 14:25:22 +0000
commit9821bddfcb3c94cea13b7f19bcb27845b0dc1ed8 (patch)
treeab4466808ccf038b297eeec167795935f6548d73 /lib/sqlalchemy
parent00928a1cf041762e846c4cb2bde4f0650d79ee5c (diff)
parent7baf42883f177a6f666a1cb550f4357aa7606a25 (diff)
downloadsqlalchemy-9821bddfcb3c94cea13b7f19bcb27845b0dc1ed8.tar.gz
Merge "Add warn_deprecated_limited feature"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/util/deprecations.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py
index 8ea8e8695..e0669c4e8 100644
--- a/lib/sqlalchemy/util/deprecations.py
+++ b/lib/sqlalchemy/util/deprecations.py
@@ -12,6 +12,7 @@ import re
import warnings
from . import compat
+from .langhelpers import _hash_limit_string
from .langhelpers import decorator
from .langhelpers import inject_docstring_text
from .langhelpers import inject_param_text
@@ -29,6 +30,16 @@ def warn_deprecated(msg, version, stacklevel=3):
_warn_with_version(msg, version, exc.SADeprecationWarning, stacklevel)
+def warn_deprecated_limited(msg, args, version, stacklevel=3):
+ """Issue a deprecation warning with a parameterized string,
+ limiting the number of registrations.
+
+ """
+ if args:
+ msg = _hash_limit_string(msg, 10, args)
+ _warn_with_version(msg, version, exc.SADeprecationWarning, stacklevel)
+
+
def warn_deprecated_20(msg, stacklevel=3):
msg += " (Background on SQLAlchemy 2.0 at: http://sqlalche.me/e/b8d9)"