44from typing import TYPE_CHECKING , Optional , Union , cast
55
66if TYPE_CHECKING :
7+ from alembic .migration import MigrationContext
8+ from alembic .operations .ops import MigrationScript , UpgradeOps
79 from click import Group
810
911 from advanced_alchemy .config import SQLAlchemyAsyncConfig , SQLAlchemySyncConfig
10- from alembic .migration import MigrationContext
11- from alembic .operations .ops import MigrationScript , UpgradeOps
1212
1313__all__ = ("add_migration_commands" , "get_alchemy_group" )
1414
@@ -157,7 +157,7 @@ def show_database_revision(bind_key: Optional[str], verbose: bool) -> None: # p
157157 """Show current database revision."""
158158 from advanced_alchemy .alembic .commands import AlembicCommands
159159
160- ctx = click .get_current_context ()
160+ ctx = cast ( " click.Context" , click . get_current_context () )
161161 console .rule ("[yellow]Listing current revision[/]" , align = "left" )
162162 sqlalchemy_config = get_config_by_bind_key (ctx , bind_key )
163163 alembic_commands = AlembicCommands (sqlalchemy_config = sqlalchemy_config )
@@ -189,7 +189,7 @@ def downgrade_database( # pyright: ignore[reportUnusedFunction]
189189
190190 from advanced_alchemy .alembic .commands import AlembicCommands
191191
192- ctx = click .get_current_context ()
192+ ctx = cast ( " click.Context" , click . get_current_context () )
193193 console .rule ("[yellow]Starting database downgrade process[/]" , align = "left" )
194194 input_confirmed = (
195195 True
@@ -227,7 +227,7 @@ def upgrade_database( # pyright: ignore[reportUnusedFunction]
227227
228228 from advanced_alchemy .alembic .commands import AlembicCommands
229229
230- ctx = click .get_current_context ()
230+ ctx = cast ( " click.Context" , click . get_current_context () )
231231 console .rule ("[yellow]Starting database upgrade process[/]" , align = "left" )
232232 input_confirmed = (
233233 True
@@ -248,7 +248,7 @@ def stamp(bind_key: Optional[str], revision: str) -> None: # pyright: ignore[re
248248 """Stamp the revision table with the given revision."""
249249 from advanced_alchemy .alembic .commands import AlembicCommands
250250
251- ctx = click .get_current_context ()
251+ ctx = cast ( " click.Context" , click . get_current_context () )
252252 sqlalchemy_config = get_config_by_bind_key (ctx , bind_key )
253253 alembic_commands = AlembicCommands (sqlalchemy_config = sqlalchemy_config )
254254 alembic_commands .stamp (revision = revision )
@@ -274,7 +274,7 @@ def init_alembic( # pyright: ignore[reportUnusedFunction]
274274
275275 from advanced_alchemy .alembic .commands import AlembicCommands
276276
277- ctx = click .get_current_context ()
277+ ctx = cast ( " click.Context" , click . get_current_context () )
278278 console .rule ("[yellow]Initializing database migrations." , align = "left" )
279279 input_confirmed = (
280280 True if no_prompt else Confirm .ask ("[bold]Are you sure you want initialize migrations for the project?[/]" )
@@ -345,7 +345,7 @@ def process_revision_directives(
345345 )
346346 directives .clear ()
347347
348- ctx = click .get_current_context ()
348+ ctx = cast ( " click.Context" , click . get_current_context () )
349349 console .rule ("[yellow]Starting database upgrade process[/]" , align = "left" )
350350 if message is None :
351351 message = "autogenerated" if no_prompt else Prompt .ask ("Please enter a message describing this revision" )
@@ -375,7 +375,7 @@ def drop_all(bind_key: Optional[str], no_prompt: bool) -> None: # pyright: igno
375375 from advanced_alchemy .alembic .utils import drop_all
376376 from advanced_alchemy .base import metadata_registry
377377
378- ctx = click .get_current_context ()
378+ ctx = cast ( " click.Context" , click . get_current_context () )
379379 console .rule ("[yellow]Dropping all tables from the database[/]" , align = "left" )
380380 input_confirmed = no_prompt or Confirm .ask (
381381 "[bold red]Are you sure you want to drop all tables from the database?"
@@ -418,7 +418,7 @@ def dump_table_data(bind_key: Optional[str], table_names: tuple[str, ...], dump_
418418 from advanced_alchemy .alembic .utils import dump_tables
419419 from advanced_alchemy .base import metadata_registry , orm_registry
420420
421- ctx = click .get_current_context ()
421+ ctx = cast ( " click.Context" , click . get_current_context () )
422422 all_tables = "*" in table_names
423423
424424 if all_tables and not Confirm .ask (
0 commit comments