]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
ensure connection is not None
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Oct 2021 19:58:37 +0000 (15:58 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Oct 2021 20:01:40 +0000 (16:01 -0400)
the inspect() API changed in
https://github.com/sqlalchemy/sqlalchemy2-stubs/commit/68f8417888456588714fcced1c6799f3eb00ff2d
to be more accurate which correctly appears to necessitate a
type check in Alembic AutogenContext.inspector() to ensure
"self.connection" isn't None

Change-Id: Icb3c73be62dc14d9a8f88e0723c3651b6628739a

alembic/autogenerate/api.py

index 3b23dcd21ba8328e6b5d46919b3c3dd1a69d1d10..27da02c46fe9a77b0dcab84a229789ff8e4e352d 100644 (file)
@@ -341,6 +341,11 @@ class AutogenContext:
 
     @util.memoized_property
     def inspector(self) -> "Inspector":
+        if self.connection is None:
+            raise TypeError(
+                "can't return inspector as this "
+                "AutogenContext has no database connection"
+            )
         return inspect(self.connection)
 
     @contextlib.contextmanager