From: Mike Bayer Date: Sun, 8 Jun 2025 20:14:19 +0000 (-0400) Subject: updates for mypy 1.16 X-Git-Tag: rel_1_16_2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c072e67aa91eb871a8123eaa26393fd568cc3f2e;p=thirdparty%2Fsqlalchemy%2Falembic.git updates for mypy 1.16 some errors go away, others come in. basically moving ignores around. need to pin to 1.16 at the lowest as these would now fail on earlier mypy versions Change-Id: Ia46084c69f1496ad77e215aab3fe1e6104361a96 --- diff --git a/alembic/autogenerate/compare.py b/alembic/autogenerate/compare.py index 66e31ca4..cf43729b 100644 --- a/alembic/autogenerate/compare.py +++ b/alembic/autogenerate/compare.py @@ -1282,7 +1282,7 @@ def _compare_foreign_keys( obj.const, obj.name, "foreign_key_constraint", False, compare_to ): modify_table_ops.ops.append( - ops.CreateForeignKeyOp.from_constraint(const.const) # type: ignore[has-type] # noqa: E501 + ops.CreateForeignKeyOp.from_constraint(const.const) ) log.info( diff --git a/alembic/autogenerate/rewriter.py b/alembic/autogenerate/rewriter.py index 8994dcf8..1d44b5c3 100644 --- a/alembic/autogenerate/rewriter.py +++ b/alembic/autogenerate/rewriter.py @@ -177,7 +177,7 @@ class Rewriter: ) upgrade_ops_list.append(ret[0]) - directive.upgrade_ops = upgrade_ops_list # type: ignore + directive.upgrade_ops = upgrade_ops_list downgrade_ops_list: List[DowngradeOps] = [] for downgrade_ops in directive.downgrade_ops_list: @@ -187,7 +187,7 @@ class Rewriter: "Can only return single object for DowngradeOps traverse" ) downgrade_ops_list.append(ret[0]) - directive.downgrade_ops = downgrade_ops_list # type: ignore + directive.downgrade_ops = downgrade_ops_list @_traverse.dispatch_for(ops.OpContainer) def _traverse_op_container( diff --git a/alembic/runtime/environment.py b/alembic/runtime/environment.py index 1ff71eef..80ca2b6c 100644 --- a/alembic/runtime/environment.py +++ b/alembic/runtime/environment.py @@ -338,7 +338,7 @@ class EnvironmentContext(util.ModuleClsProxy): line. """ - return self.context_opts.get("tag", None) # type: ignore[no-any-return] # noqa: E501 + return self.context_opts.get("tag", None) @overload def get_x_argument(self, as_dictionary: Literal[False]) -> List[str]: ... diff --git a/alembic/runtime/migration.py b/alembic/runtime/migration.py index ac431a62..c1c7b0fc 100644 --- a/alembic/runtime/migration.py +++ b/alembic/runtime/migration.py @@ -175,7 +175,11 @@ class MigrationContext: opts["output_encoding"], ) else: - self.output_buffer = opts.get("output_buffer", sys.stdout) + self.output_buffer = opts.get( + "output_buffer", sys.stdout + ) # type:ignore[assignment] # noqa: E501 + + self.transactional_ddl = transactional_ddl self._user_compare_type = opts.get("compare_type", True) self._user_compare_server_default = opts.get( diff --git a/alembic/script/base.py b/alembic/script/base.py index 8c5d763f..16c014b8 100644 --- a/alembic/script/base.py +++ b/alembic/script/base.py @@ -846,7 +846,7 @@ class Script(revision.Revision): doc = doc.decode( # type: ignore[attr-defined] self.module._alembic_source_encoding ) - return doc.strip() # type: ignore[union-attr] + return doc.strip() else: return "" diff --git a/tox.ini b/tox.ini index 087db7ed..fad7ec27 100644 --- a/tox.ini +++ b/tox.ini @@ -70,7 +70,7 @@ basepython = python312 python313 deps= - mypy + mypy>=1.16.0 sqlalchemy>=2 mako # is imported in alembic/testing and mypy complains if it's not installed.