diff options
author | Gord Thompson <gord@gordthompson.com> | 2020-04-24 06:23:19 -0600 |
---|---|---|
committer | Gord Thompson <gord@gordthompson.com> | 2020-05-01 12:12:57 -0600 |
commit | 7baf42883f177a6f666a1cb550f4357aa7606a25 (patch) | |
tree | c2a24f9bbc9608939d754a7eb9c3d1598fef660c /lib | |
parent | 31898e90618e946aca3eef2914b03e8534c464aa (diff) | |
download | sqlalchemy-7baf42883f177a6f666a1cb550f4357aa7606a25.tar.gz |
Add warn_deprecated_limited feature
Fixes: #5268
Change-Id: I2f976048af4f8d6dd03a14efa31d179bd7324ba6
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/util/deprecations.py | 11 |
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)" |