alembic 1.13.0__py3-none-any.whl → 1.13.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. alembic/__init__.py +1 -1
  2. alembic/autogenerate/__init__.py +10 -10
  3. alembic/autogenerate/api.py +6 -4
  4. alembic/autogenerate/compare.py +5 -4
  5. alembic/autogenerate/render.py +9 -9
  6. alembic/autogenerate/rewriter.py +26 -13
  7. alembic/command.py +3 -1
  8. alembic/config.py +20 -9
  9. alembic/context.pyi +10 -5
  10. alembic/ddl/__init__.py +1 -1
  11. alembic/ddl/_autogen.py +4 -2
  12. alembic/ddl/base.py +12 -9
  13. alembic/ddl/impl.py +5 -2
  14. alembic/ddl/mssql.py +4 -1
  15. alembic/ddl/mysql.py +5 -3
  16. alembic/ddl/oracle.py +4 -1
  17. alembic/ddl/postgresql.py +16 -9
  18. alembic/ddl/sqlite.py +8 -6
  19. alembic/op.pyi +46 -8
  20. alembic/operations/base.py +70 -14
  21. alembic/operations/batch.py +7 -8
  22. alembic/operations/ops.py +52 -30
  23. alembic/operations/schemaobj.py +5 -4
  24. alembic/operations/toimpl.py +3 -0
  25. alembic/runtime/environment.py +15 -6
  26. alembic/runtime/migration.py +27 -11
  27. alembic/script/base.py +13 -15
  28. alembic/script/revision.py +30 -17
  29. alembic/script/write_hooks.py +3 -0
  30. alembic/util/__init__.py +31 -31
  31. alembic/util/compat.py +25 -8
  32. alembic/util/langhelpers.py +78 -33
  33. alembic/util/messaging.py +6 -3
  34. alembic/util/pyfiles.py +7 -3
  35. alembic/util/sqla_compat.py +43 -14
  36. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/METADATA +1 -1
  37. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/RECORD +41 -41
  38. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/LICENSE +0 -0
  39. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/WHEEL +0 -0
  40. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/entry_points.txt +0 -0
  41. {alembic-1.13.0.dist-info → alembic-1.13.1.dist-info}/top_level.txt +0 -0
alembic/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from . import context
2
2
  from . import op
3
3
 
4
- __version__ = "1.13.0"
4
+ __version__ = "1.13.1"
@@ -1,10 +1,10 @@
1
- from .api import _render_migration_diffs
2
- from .api import compare_metadata
3
- from .api import produce_migrations
4
- from .api import render_python_code
5
- from .api import RevisionContext
6
- from .compare import _produce_net_changes
7
- from .compare import comparators
8
- from .render import render_op_text
9
- from .render import renderers
10
- from .rewriter import Rewriter
1
+ from .api import _render_migration_diffs as _render_migration_diffs
2
+ from .api import compare_metadata as compare_metadata
3
+ from .api import produce_migrations as produce_migrations
4
+ from .api import render_python_code as render_python_code
5
+ from .api import RevisionContext as RevisionContext
6
+ from .compare import _produce_net_changes as _produce_net_changes
7
+ from .compare import comparators as comparators
8
+ from .render import render_op_text as render_op_text
9
+ from .render import renderers as renderers
10
+ from .rewriter import Rewriter as Rewriter
@@ -28,6 +28,7 @@ if TYPE_CHECKING:
28
28
  from sqlalchemy.engine import Inspector
29
29
  from sqlalchemy.sql.schema import MetaData
30
30
  from sqlalchemy.sql.schema import SchemaItem
31
+ from sqlalchemy.sql.schema import Table
31
32
 
32
33
  from ..config import Config
33
34
  from ..operations.ops import DowngradeOps
@@ -165,6 +166,7 @@ def compare_metadata(context: MigrationContext, metadata: MetaData) -> Any:
165
166
  """
166
167
 
167
168
  migration_script = produce_migrations(context, metadata)
169
+ assert migration_script.upgrade_ops is not None
168
170
  return migration_script.upgrade_ops.as_diffs()
169
171
 
170
172
 
@@ -331,7 +333,7 @@ class AutogenContext:
331
333
  self,
332
334
  migration_context: MigrationContext,
333
335
  metadata: Optional[MetaData] = None,
334
- opts: Optional[dict] = None,
336
+ opts: Optional[Dict[str, Any]] = None,
335
337
  autogenerate: bool = True,
336
338
  ) -> None:
337
339
  if (
@@ -465,7 +467,7 @@ class AutogenContext:
465
467
  run_filters = run_object_filters
466
468
 
467
469
  @util.memoized_property
468
- def sorted_tables(self):
470
+ def sorted_tables(self) -> List[Table]:
469
471
  """Return an aggregate of the :attr:`.MetaData.sorted_tables`
470
472
  collection(s).
471
473
 
@@ -481,7 +483,7 @@ class AutogenContext:
481
483
  return result
482
484
 
483
485
  @util.memoized_property
484
- def table_key_to_table(self):
486
+ def table_key_to_table(self) -> Dict[str, Table]:
485
487
  """Return an aggregate of the :attr:`.MetaData.tables` dictionaries.
486
488
 
487
489
  The :attr:`.MetaData.tables` collection is a dictionary of table key
@@ -492,7 +494,7 @@ class AutogenContext:
492
494
  objects contain the same table key, an exception is raised.
493
495
 
494
496
  """
495
- result = {}
497
+ result: Dict[str, Table] = {}
496
498
  for m in util.to_list(self.metadata):
497
499
  intersect = set(result).intersection(set(m.tables))
498
500
  if intersect:
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import contextlib
@@ -577,9 +580,7 @@ def _compare_indexes_and_uniques(
577
580
  # 5. index things by name, for those objects that have names
578
581
  metadata_names = {
579
582
  cast(str, c.md_name_to_sql_name(autogen_context)): c
580
- for c in metadata_unique_constraints_sig.union(
581
- metadata_indexes_sig # type:ignore[arg-type]
582
- )
583
+ for c in metadata_unique_constraints_sig.union(metadata_indexes_sig)
583
584
  if c.is_named
584
585
  }
585
586
 
@@ -1240,7 +1241,7 @@ def _compare_foreign_keys(
1240
1241
  obj.const, obj.name, "foreign_key_constraint", False, compare_to
1241
1242
  ):
1242
1243
  modify_table_ops.ops.append(
1243
- ops.CreateForeignKeyOp.from_constraint(const.const)
1244
+ ops.CreateForeignKeyOp.from_constraint(const.const) # type: ignore[has-type] # noqa: E501
1244
1245
  )
1245
1246
 
1246
1247
  log.info(
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  from io import StringIO
@@ -849,7 +852,7 @@ def _render_Variant_type(
849
852
  ) -> str:
850
853
  base_type, variant_mapping = sqla_compat._get_variant_mapping(type_)
851
854
  base = _repr_type(base_type, autogen_context, _skip_variants=True)
852
- assert base is not None and base is not False
855
+ assert base is not None and base is not False # type: ignore[comparison-overlap] # noqa:E501
853
856
  for dialect in sorted(variant_mapping):
854
857
  typ = variant_mapping[dialect]
855
858
  base += ".with_variant(%s, %r)" % (
@@ -946,7 +949,7 @@ def _fk_colspec(
946
949
  won't fail if the remote table can't be resolved.
947
950
 
948
951
  """
949
- colspec = fk._get_colspec() # type:ignore[attr-defined]
952
+ colspec = fk._get_colspec()
950
953
  tokens = colspec.split(".")
951
954
  tname, colname = tokens[-2:]
952
955
 
@@ -1016,8 +1019,7 @@ def _render_foreign_key(
1016
1019
  % {
1017
1020
  "prefix": _sqlalchemy_autogenerate_prefix(autogen_context),
1018
1021
  "cols": ", ".join(
1019
- "%r" % _ident(cast("Column", f.parent).name)
1020
- for f in constraint.elements
1022
+ repr(_ident(f.parent.name)) for f in constraint.elements
1021
1023
  ),
1022
1024
  "refcols": ", ".join(
1023
1025
  repr(_fk_colspec(f, apply_metadata_schema, namespace_metadata))
@@ -1058,12 +1060,10 @@ def _render_check_constraint(
1058
1060
  # ideally SQLAlchemy would give us more of a first class
1059
1061
  # way to detect this.
1060
1062
  if (
1061
- constraint._create_rule # type:ignore[attr-defined]
1062
- and hasattr(
1063
- constraint._create_rule, "target" # type:ignore[attr-defined]
1064
- )
1063
+ constraint._create_rule
1064
+ and hasattr(constraint._create_rule, "target")
1065
1065
  and isinstance(
1066
- constraint._create_rule.target, # type:ignore[attr-defined]
1066
+ constraint._create_rule.target,
1067
1067
  sqltypes.TypeEngine,
1068
1068
  )
1069
1069
  ):
@@ -4,7 +4,7 @@ from typing import Any
4
4
  from typing import Callable
5
5
  from typing import Iterator
6
6
  from typing import List
7
- from typing import Optional
7
+ from typing import Tuple
8
8
  from typing import Type
9
9
  from typing import TYPE_CHECKING
10
10
  from typing import Union
@@ -16,12 +16,18 @@ if TYPE_CHECKING:
16
16
  from ..operations.ops import AddColumnOp
17
17
  from ..operations.ops import AlterColumnOp
18
18
  from ..operations.ops import CreateTableOp
19
+ from ..operations.ops import DowngradeOps
19
20
  from ..operations.ops import MigrateOperation
20
21
  from ..operations.ops import MigrationScript
21
22
  from ..operations.ops import ModifyTableOps
22
23
  from ..operations.ops import OpContainer
23
- from ..runtime.environment import _GetRevArg
24
+ from ..operations.ops import UpgradeOps
24
25
  from ..runtime.migration import MigrationContext
26
+ from ..script.revision import _GetRevArg
27
+
28
+ ProcessRevisionDirectiveFn = Callable[
29
+ ["MigrationContext", "_GetRevArg", List["MigrationScript"]], None
30
+ ]
25
31
 
26
32
 
27
33
  class Rewriter:
@@ -52,15 +58,21 @@ class Rewriter:
52
58
 
53
59
  _traverse = util.Dispatcher()
54
60
 
55
- _chained: Optional[Rewriter] = None
61
+ _chained: Tuple[Union[ProcessRevisionDirectiveFn, Rewriter], ...] = ()
56
62
 
57
63
  def __init__(self) -> None:
58
64
  self.dispatch = util.Dispatcher()
59
65
 
60
- def chain(self, other: Rewriter) -> Rewriter:
66
+ def chain(
67
+ self,
68
+ other: Union[
69
+ ProcessRevisionDirectiveFn,
70
+ Rewriter,
71
+ ],
72
+ ) -> Rewriter:
61
73
  """Produce a "chain" of this :class:`.Rewriter` to another.
62
74
 
63
- This allows two rewriters to operate serially on a stream,
75
+ This allows two or more rewriters to operate serially on a stream,
64
76
  e.g.::
65
77
 
66
78
  writer1 = autogenerate.Rewriter()
@@ -89,7 +101,7 @@ class Rewriter:
89
101
  """
90
102
  wr = self.__class__.__new__(self.__class__)
91
103
  wr.__dict__.update(self.__dict__)
92
- wr._chained = other
104
+ wr._chained += (other,)
93
105
  return wr
94
106
 
95
107
  def rewrites(
@@ -101,7 +113,7 @@ class Rewriter:
101
113
  Type[CreateTableOp],
102
114
  Type[ModifyTableOps],
103
115
  ],
104
- ) -> Callable:
116
+ ) -> Callable[..., Any]:
105
117
  """Register a function as rewriter for a given type.
106
118
 
107
119
  The function should receive three arguments, which are
@@ -146,8 +158,8 @@ class Rewriter:
146
158
  directives: List[MigrationScript],
147
159
  ) -> None:
148
160
  self.process_revision_directives(context, revision, directives)
149
- if self._chained:
150
- self._chained(context, revision, directives)
161
+ for process_revision_directives in self._chained:
162
+ process_revision_directives(context, revision, directives)
151
163
 
152
164
  @_traverse.dispatch_for(ops.MigrationScript)
153
165
  def _traverse_script(
@@ -156,7 +168,7 @@ class Rewriter:
156
168
  revision: _GetRevArg,
157
169
  directive: MigrationScript,
158
170
  ) -> None:
159
- upgrade_ops_list = []
171
+ upgrade_ops_list: List[UpgradeOps] = []
160
172
  for upgrade_ops in directive.upgrade_ops_list:
161
173
  ret = self._traverse_for(context, revision, upgrade_ops)
162
174
  if len(ret) != 1:
@@ -164,9 +176,10 @@ class Rewriter:
164
176
  "Can only return single object for UpgradeOps traverse"
165
177
  )
166
178
  upgrade_ops_list.append(ret[0])
167
- directive.upgrade_ops = upgrade_ops_list
168
179
 
169
- downgrade_ops_list = []
180
+ directive.upgrade_ops = upgrade_ops_list # type: ignore
181
+
182
+ downgrade_ops_list: List[DowngradeOps] = []
170
183
  for downgrade_ops in directive.downgrade_ops_list:
171
184
  ret = self._traverse_for(context, revision, downgrade_ops)
172
185
  if len(ret) != 1:
@@ -174,7 +187,7 @@ class Rewriter:
174
187
  "Can only return single object for DowngradeOps traverse"
175
188
  )
176
189
  downgrade_ops_list.append(ret[0])
177
- directive.downgrade_ops = downgrade_ops_list
190
+ directive.downgrade_ops = downgrade_ops_list # type: ignore
178
191
 
179
192
  @_traverse.dispatch_for(ops.OpContainer)
180
193
  def _traverse_op_container(
alembic/command.py CHANGED
@@ -1,3 +1,5 @@
1
+ # mypy: allow-untyped-defs, allow-untyped-calls
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import os
@@ -18,7 +20,7 @@ if TYPE_CHECKING:
18
20
  from .runtime.environment import ProcessRevisionDirectiveFn
19
21
 
20
22
 
21
- def list_templates(config: Config):
23
+ def list_templates(config: Config) -> None:
22
24
  """List available templates.
23
25
 
24
26
  :param config: a :class:`.Config` object.
alembic/config.py CHANGED
@@ -12,6 +12,7 @@ from typing import Dict
12
12
  from typing import Mapping
13
13
  from typing import Optional
14
14
  from typing import overload
15
+ from typing import Sequence
15
16
  from typing import TextIO
16
17
  from typing import Union
17
18
 
@@ -104,7 +105,7 @@ class Config:
104
105
  stdout: TextIO = sys.stdout,
105
106
  cmd_opts: Optional[Namespace] = None,
106
107
  config_args: Mapping[str, Any] = util.immutabledict(),
107
- attributes: Optional[dict] = None,
108
+ attributes: Optional[Dict[str, Any]] = None,
108
109
  ) -> None:
109
110
  """Construct a new :class:`.Config`"""
110
111
  self.config_file_name = file_
@@ -140,7 +141,7 @@ class Config:
140
141
  """
141
142
 
142
143
  @util.memoized_property
143
- def attributes(self):
144
+ def attributes(self) -> Dict[str, Any]:
144
145
  """A Python dictionary for storage of additional state.
145
146
 
146
147
 
@@ -159,7 +160,7 @@ class Config:
159
160
  """
160
161
  return {}
161
162
 
162
- def print_stdout(self, text: str, *arg) -> None:
163
+ def print_stdout(self, text: str, *arg: Any) -> None:
163
164
  """Render a message to standard out.
164
165
 
165
166
  When :meth:`.Config.print_stdout` is called with additional args
@@ -183,7 +184,7 @@ class Config:
183
184
  util.write_outstream(self.stdout, output, "\n", **self.messaging_opts)
184
185
 
185
186
  @util.memoized_property
186
- def file_config(self):
187
+ def file_config(self) -> ConfigParser:
187
188
  """Return the underlying ``ConfigParser`` object.
188
189
 
189
190
  Direct access to the .ini file is available here,
@@ -321,7 +322,9 @@ class Config:
321
322
  ) -> Optional[str]:
322
323
  ...
323
324
 
324
- def get_main_option(self, name, default=None):
325
+ def get_main_option(
326
+ self, name: str, default: Optional[str] = None
327
+ ) -> Optional[str]:
325
328
  """Return an option from the 'main' section of the .ini file.
326
329
 
327
330
  This defaults to being a key from the ``[alembic]``
@@ -351,7 +354,9 @@ class CommandLine:
351
354
  self._generate_args(prog)
352
355
 
353
356
  def _generate_args(self, prog: Optional[str]) -> None:
354
- def add_options(fn, parser, positional, kwargs):
357
+ def add_options(
358
+ fn: Any, parser: Any, positional: Any, kwargs: Any
359
+ ) -> None:
355
360
  kwargs_opts = {
356
361
  "template": (
357
362
  "-t",
@@ -554,7 +559,9 @@ class CommandLine:
554
559
  )
555
560
  subparsers = parser.add_subparsers()
556
561
 
557
- positional_translations = {command.stamp: {"revision": "revisions"}}
562
+ positional_translations: Dict[Any, Any] = {
563
+ command.stamp: {"revision": "revisions"}
564
+ }
558
565
 
559
566
  for fn in [getattr(command, n) for n in dir(command)]:
560
567
  if (
@@ -609,7 +616,7 @@ class CommandLine:
609
616
  else:
610
617
  util.err(str(e), **config.messaging_opts)
611
618
 
612
- def main(self, argv=None):
619
+ def main(self, argv: Optional[Sequence[str]] = None) -> None:
613
620
  options = self.parser.parse_args(argv)
614
621
  if not hasattr(options, "cmd"):
615
622
  # see http://bugs.python.org/issue9253, argparse
@@ -624,7 +631,11 @@ class CommandLine:
624
631
  self.run_cmd(cfg, options)
625
632
 
626
633
 
627
- def main(argv=None, prog=None, **kwargs):
634
+ def main(
635
+ argv: Optional[Sequence[str]] = None,
636
+ prog: Optional[str] = None,
637
+ **kwargs: Any,
638
+ ) -> None:
628
639
  """The console runner function for Alembic."""
629
640
 
630
641
  CommandLine(prog=prog).main(argv=argv)
alembic/context.pyi CHANGED
@@ -160,8 +160,8 @@ def configure(
160
160
  MigrationContext,
161
161
  Column[Any],
162
162
  Column[Any],
163
- TypeEngine,
164
- TypeEngine,
163
+ TypeEngine[Any],
164
+ TypeEngine[Any],
165
165
  ],
166
166
  Optional[bool],
167
167
  ],
@@ -636,7 +636,8 @@ def configure(
636
636
  """
637
637
 
638
638
  def execute(
639
- sql: Union[Executable, str], execution_options: Optional[dict] = None
639
+ sql: Union[Executable, str],
640
+ execution_options: Optional[Dict[str, Any]] = None,
640
641
  ) -> None:
641
642
  """Execute the given SQL using the current change context.
642
643
 
@@ -759,7 +760,11 @@ def get_x_argument(
759
760
  The return value is a list, returned directly from the ``argparse``
760
761
  structure. If ``as_dictionary=True`` is passed, the ``x`` arguments
761
762
  are parsed using ``key=value`` format into a dictionary that is
762
- then returned.
763
+ then returned. If there is no ``=`` in the argument, value is an empty
764
+ string.
765
+
766
+ .. versionchanged:: 1.13.1 Support ``as_dictionary=True`` when
767
+ arguments are passed without the ``=`` symbol.
763
768
 
764
769
  For example, to support passing a database URL on the command line,
765
770
  the standard ``env.py`` script can be modified like this::
@@ -801,7 +806,7 @@ def is_offline_mode() -> bool:
801
806
 
802
807
  """
803
808
 
804
- def is_transactional_ddl():
809
+ def is_transactional_ddl() -> bool:
805
810
  """Return True if the context is configured to expect a
806
811
  transactional DDL capable backend.
807
812
 
alembic/ddl/__init__.py CHANGED
@@ -3,4 +3,4 @@ from . import mysql
3
3
  from . import oracle
4
4
  from . import postgresql
5
5
  from . import sqlite
6
- from .impl import DefaultImpl
6
+ from .impl import DefaultImpl as DefaultImpl
alembic/ddl/_autogen.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  from typing import Any
@@ -19,7 +22,6 @@ from sqlalchemy.sql.schema import Index
19
22
  from sqlalchemy.sql.schema import UniqueConstraint
20
23
  from typing_extensions import TypeGuard
21
24
 
22
- from alembic.ddl.base import _fk_spec
23
25
  from .. import util
24
26
  from ..util import sqla_compat
25
27
 
@@ -275,7 +277,7 @@ class _fk_constraint_sig(_constraint_sig[ForeignKeyConstraint]):
275
277
  ondelete,
276
278
  deferrable,
277
279
  initially,
278
- ) = _fk_spec(const)
280
+ ) = sqla_compat._fk_spec(const)
279
281
 
280
282
  self._sig: Tuple[Any, ...] = (
281
283
  self.source_schema,
alembic/ddl/base.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import functools
@@ -173,7 +176,7 @@ class ColumnComment(AlterColumn):
173
176
  self.comment = comment
174
177
 
175
178
 
176
- @compiles(RenameTable)
179
+ @compiles(RenameTable) # type: ignore[misc]
177
180
  def visit_rename_table(
178
181
  element: RenameTable, compiler: DDLCompiler, **kw
179
182
  ) -> str:
@@ -183,7 +186,7 @@ def visit_rename_table(
183
186
  )
184
187
 
185
188
 
186
- @compiles(AddColumn)
189
+ @compiles(AddColumn) # type: ignore[misc]
187
190
  def visit_add_column(element: AddColumn, compiler: DDLCompiler, **kw) -> str:
188
191
  return "%s %s" % (
189
192
  alter_table(compiler, element.table_name, element.schema),
@@ -191,7 +194,7 @@ def visit_add_column(element: AddColumn, compiler: DDLCompiler, **kw) -> str:
191
194
  )
192
195
 
193
196
 
194
- @compiles(DropColumn)
197
+ @compiles(DropColumn) # type: ignore[misc]
195
198
  def visit_drop_column(element: DropColumn, compiler: DDLCompiler, **kw) -> str:
196
199
  return "%s %s" % (
197
200
  alter_table(compiler, element.table_name, element.schema),
@@ -199,7 +202,7 @@ def visit_drop_column(element: DropColumn, compiler: DDLCompiler, **kw) -> str:
199
202
  )
200
203
 
201
204
 
202
- @compiles(ColumnNullable)
205
+ @compiles(ColumnNullable) # type: ignore[misc]
203
206
  def visit_column_nullable(
204
207
  element: ColumnNullable, compiler: DDLCompiler, **kw
205
208
  ) -> str:
@@ -210,7 +213,7 @@ def visit_column_nullable(
210
213
  )
211
214
 
212
215
 
213
- @compiles(ColumnType)
216
+ @compiles(ColumnType) # type: ignore[misc]
214
217
  def visit_column_type(element: ColumnType, compiler: DDLCompiler, **kw) -> str:
215
218
  return "%s %s %s" % (
216
219
  alter_table(compiler, element.table_name, element.schema),
@@ -219,7 +222,7 @@ def visit_column_type(element: ColumnType, compiler: DDLCompiler, **kw) -> str:
219
222
  )
220
223
 
221
224
 
222
- @compiles(ColumnName)
225
+ @compiles(ColumnName) # type: ignore[misc]
223
226
  def visit_column_name(element: ColumnName, compiler: DDLCompiler, **kw) -> str:
224
227
  return "%s RENAME %s TO %s" % (
225
228
  alter_table(compiler, element.table_name, element.schema),
@@ -228,7 +231,7 @@ def visit_column_name(element: ColumnName, compiler: DDLCompiler, **kw) -> str:
228
231
  )
229
232
 
230
233
 
231
- @compiles(ColumnDefault)
234
+ @compiles(ColumnDefault) # type: ignore[misc]
232
235
  def visit_column_default(
233
236
  element: ColumnDefault, compiler: DDLCompiler, **kw
234
237
  ) -> str:
@@ -241,7 +244,7 @@ def visit_column_default(
241
244
  )
242
245
 
243
246
 
244
- @compiles(ComputedColumnDefault)
247
+ @compiles(ComputedColumnDefault) # type: ignore[misc]
245
248
  def visit_computed_column(
246
249
  element: ComputedColumnDefault, compiler: DDLCompiler, **kw
247
250
  ):
@@ -251,7 +254,7 @@ def visit_computed_column(
251
254
  )
252
255
 
253
256
 
254
- @compiles(IdentityColumnDefault)
257
+ @compiles(IdentityColumnDefault) # type: ignore[misc]
255
258
  def visit_identity_column(
256
259
  element: IdentityColumnDefault, compiler: DDLCompiler, **kw
257
260
  ):
alembic/ddl/impl.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import logging
@@ -23,8 +26,8 @@ from sqlalchemy import text
23
26
 
24
27
  from . import _autogen
25
28
  from . import base
26
- from ._autogen import _constraint_sig
27
- from ._autogen import ComparisonResult
29
+ from ._autogen import _constraint_sig as _constraint_sig
30
+ from ._autogen import ComparisonResult as ComparisonResult
28
31
  from .. import util
29
32
  from ..util import sqla_compat
30
33
 
alembic/ddl/mssql.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import re
@@ -9,7 +12,6 @@ from typing import TYPE_CHECKING
9
12
  from typing import Union
10
13
 
11
14
  from sqlalchemy import types as sqltypes
12
- from sqlalchemy.ext.compiler import compiles
13
15
  from sqlalchemy.schema import Column
14
16
  from sqlalchemy.schema import CreateIndex
15
17
  from sqlalchemy.sql.base import Executable
@@ -30,6 +32,7 @@ from .base import RenameTable
30
32
  from .impl import DefaultImpl
31
33
  from .. import util
32
34
  from ..util import sqla_compat
35
+ from ..util.sqla_compat import compiles
33
36
 
34
37
  if TYPE_CHECKING:
35
38
  from typing import Literal
alembic/ddl/mysql.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import re
@@ -8,7 +11,6 @@ from typing import Union
8
11
 
9
12
  from sqlalchemy import schema
10
13
  from sqlalchemy import types as sqltypes
11
- from sqlalchemy.ext.compiler import compiles
12
14
 
13
15
  from .base import alter_table
14
16
  from .base import AlterColumn
@@ -23,6 +25,7 @@ from .. import util
23
25
  from ..util import sqla_compat
24
26
  from ..util.sqla_compat import _is_mariadb
25
27
  from ..util.sqla_compat import _is_type_bound
28
+ from ..util.sqla_compat import compiles
26
29
 
27
30
  if TYPE_CHECKING:
28
31
  from typing import Literal
@@ -160,8 +163,7 @@ class MySQLImpl(DefaultImpl):
160
163
  ) -> bool:
161
164
  return (
162
165
  type_ is not None
163
- and type_._type_affinity # type:ignore[attr-defined]
164
- is sqltypes.DateTime
166
+ and type_._type_affinity is sqltypes.DateTime
165
167
  and server_default is not None
166
168
  )
167
169
 
alembic/ddl/oracle.py CHANGED
@@ -1,3 +1,6 @@
1
+ # mypy: allow-untyped-defs, allow-incomplete-defs, allow-untyped-calls
2
+ # mypy: no-warn-return-any, allow-any-generics
3
+
1
4
  from __future__ import annotations
2
5
 
3
6
  import re
@@ -5,7 +8,6 @@ from typing import Any
5
8
  from typing import Optional
6
9
  from typing import TYPE_CHECKING
7
10
 
8
- from sqlalchemy.ext.compiler import compiles
9
11
  from sqlalchemy.sql import sqltypes
10
12
 
11
13
  from .base import AddColumn
@@ -22,6 +24,7 @@ from .base import format_type
22
24
  from .base import IdentityColumnDefault
23
25
  from .base import RenameTable
24
26
  from .impl import DefaultImpl
27
+ from ..util.sqla_compat import compiles
25
28
 
26
29
  if TYPE_CHECKING:
27
30
  from sqlalchemy.dialects.oracle.base import OracleDDLCompiler