diff options
Diffstat (limited to 'lib/sqlalchemy/util/deprecations.py')
-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)" |