Warnings emitted by Alembic now include a default stack level of 2, and in
some cases it's set to 3, in order to help warnings indicate more closely
where they are originating from. Pull request courtesy Ash Berlin-Taylor.
Closes: #578
Pull-request: https://github.com/sqlalchemy/alembic/pull/578
Pull-request-sha:
49d2922dc61bfc6da42a5f45b53f04032970daeb
Change-Id: I31e19cacd63a4a7ff0557d9e7f52d348f63744d6
script = ScriptDirectory.from_config(config)
if head_only:
- util.warn("--head-only is deprecated")
+ util.warn("--head-only is deprecated", stacklevel=3)
def display_version(rev, context):
if verbose:
if autoincrement is not None or existing_autoincrement is not None:
util.warn(
"autoincrement and existing_autoincrement "
- "only make sense for MySQL"
+ "only make sense for MySQL",
+ stacklevel=3,
)
if nullable is not None:
self._exec(
util.warn(
"'connection' argument to configure() is expected "
"to be a sqlalchemy.engine.Connection instance, "
- "got %r" % connection
+ "got %r" % connection,
+ stacklevel=3
)
dialect = connection.dialect
elif url:
return str(u)
-def warn(msg):
- warnings.warn(msg)
+def warn(msg, stacklevel=2):
+ warnings.warn(msg, stacklevel=stacklevel)
def msg(msg, newline=True):
--- /dev/null
+.. change::
+ :tags: bug, environment
+
+ Warnings emitted by Alembic now include a default stack level of 2, and in
+ some cases it's set to 3, in order to help warnings indicate more closely
+ where they are originating from. Pull request courtesy Ash Berlin-Taylor.
+