]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Report warnings from caller's file/line number, not utils.py
authorAsh Berlin-Taylor <ash_github@firemirror.com>
Fri, 21 Jun 2019 12:53:11 +0000 (08:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 21 Jun 2019 15:19:06 +0000 (11:19 -0400)
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

alembic/command.py
alembic/ddl/impl.py
alembic/runtime/migration.py
alembic/util/messaging.py
docs/build/unreleased/warn_depth.rst [new file with mode: 0644]

index f8c81cc15105fb6e1c013182da7b971742ea7cbe..3faafddfb337ca826249d6bc4b2144d38f5f547c 100644 (file)
@@ -476,7 +476,7 @@ def current(config, verbose=False, head_only=False):
     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:
index 5df7c040d0123acfb9554835f722336c4906143c..0843ebf1d73d62f5a8680214365516b7d23f372d 100644 (file)
@@ -156,7 +156,8 @@ class DefaultImpl(with_metaclass(ImplMeta)):
         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(
index a4ad74085514cd2baf6d0d5d4291c5e36fc5ae40..b3a98633271531541862d245c6e419edd7bf2018 100644 (file)
@@ -175,7 +175,8 @@ class MigrationContext(object):
                 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:
index 1e72c195ccb14604e031c220b1429a47431b07fe..6a30133e4d3a5e2d270521cba314fb80232006d9 100644 (file)
@@ -69,8 +69,8 @@ def obfuscate_url_pw(u):
     return str(u)
 
 
-def warn(msg):
-    warnings.warn(msg)
+def warn(msg, stacklevel=2):
+    warnings.warn(msg, stacklevel=stacklevel)
 
 
 def msg(msg, newline=True):
diff --git a/docs/build/unreleased/warn_depth.rst b/docs/build/unreleased/warn_depth.rst
new file mode 100644 (file)
index 0000000..0d82c9d
--- /dev/null
@@ -0,0 +1,7 @@
+.. 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.
+