Rather than appending to the message via the deprecation utilities,
the RemovedIn20Warning class has a custom __str__ which appends the
desired info to its message.
deprecated_since = "1.4"
"Indicates the version that started raising this deprecation warning"
+ def __str__(self):
+ return (
+ super(RemovedIn20Warning, self).__str__()
+ + " (Background on SQLAlchemy 2.0 at: http://sqlalche.me/e/b8d9)"
+ )
+
class MovedIn20Warning(RemovedIn20Warning):
"""Subtype of RemovedIn20Warning to indicate an API that moved only."""
def _warn_with_version(msg, version, type_, stacklevel, code=None):
- is_20 = issubclass(type_, exc.RemovedIn20Warning)
-
- if is_20 and not SQLALCHEMY_WARN_20:
+ if issubclass(type_, exc.RemovedIn20Warning) and not SQLALCHEMY_WARN_20:
return
- if is_20:
- msg += " (Background on SQLAlchemy 2.0 at: http://sqlalche.me/e/b8d9)"
-
warn = type_(msg, code=code)
warn.deprecated_since = version