7
7
8
8
# this is the Alembic Config object, which provides
9
9
# access to the values within the .ini file in use.
10
- config = context .config
10
+ config : context . Config = context .config
11
11
12
12
# Interpret the config file for Python logging.
13
13
# This line sets up loggers basically.
14
14
fileConfig (config .config_file_name )
15
- logger = logging .getLogger ("alembic.env" )
15
+ logger : logging . Logger = logging .getLogger ("alembic.env" )
16
16
17
17
18
18
def get_engine ():
@@ -24,7 +24,7 @@ def get_engine():
24
24
return current_app .extensions ["migrate" ].db .engine
25
25
26
26
27
- def get_engine_url ():
27
+ def get_engine_url () -> logging . Any | str :
28
28
try :
29
29
return get_engine ().url .render_as_string (hide_password = False ).replace ("%" , "%%" )
30
30
except AttributeError :
@@ -44,13 +44,13 @@ def get_engine_url():
44
44
# ... etc.
45
45
46
46
47
- def get_metadata ():
47
+ def get_metadata () -> target_db :
48
48
if hasattr (target_db , "metadatas" ):
49
49
return target_db .metadatas [None ]
50
50
return target_db .metadata
51
51
52
52
53
- def run_migrations_offline ():
53
+ def run_migrations_offline () -> None :
54
54
"""Run migrations in 'offline' mode.
55
55
56
56
This configures the context with just a URL
@@ -70,7 +70,7 @@ def run_migrations_offline():
70
70
context .run_migrations ()
71
71
72
72
73
- def run_migrations_online ():
73
+ def run_migrations_online () -> None :
74
74
"""Run migrations in 'online' mode.
75
75
76
76
In this scenario we need to create an Engine
@@ -81,7 +81,7 @@ def run_migrations_online():
81
81
# this callback is used to prevent an auto-migration from being generated
82
82
# when there are no changes to the schema
83
83
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
84
- def process_revision_directives (context , revision , directives ):
84
+ def process_revision_directives (context , revision , directives ) -> None :
85
85
if getattr (config .cmd_opts , "autogenerate" , False ):
86
86
script = directives [0 ]
87
87
if script .upgrade_ops .is_empty ():
0 commit comments