From: Mike Bayer Date: Sat, 23 Oct 2021 19:58:37 +0000 (-0400) Subject: ensure connection is not None X-Git-Tag: rel_1_7_5~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27f4133c5de1b721489e9af733038d3dc7394e79;p=thirdparty%2Fsqlalchemy%2Falembic.git ensure connection is not None 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 --- diff --git a/alembic/autogenerate/api.py b/alembic/autogenerate/api.py index 3b23dcd2..27da02c4 100644 --- a/alembic/autogenerate/api.py +++ b/alembic/autogenerate/api.py @@ -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