From 67b3ea335861d374c42d8c56f1fe1d115e2ae5d5 Mon Sep 17 00:00:00 2001 From: lulunac27a <100660343+lulunac27a@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:34:26 -0600 Subject: [PATCH] Add type hints --- migrations/env.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index 016b537..0852341 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -7,12 +7,12 @@ # this is the Alembic Config object, which provides # access to the values within the .ini file in use. -config = context.config +config: context.Config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) -logger = logging.getLogger("alembic.env") +logger: logging.Logger = logging.getLogger("alembic.env") def get_engine(): @@ -24,7 +24,7 @@ def get_engine(): return current_app.extensions["migrate"].db.engine -def get_engine_url(): +def get_engine_url() -> logging.Any | str: try: return get_engine().url.render_as_string(hide_password=False).replace("%", "%%") except AttributeError: @@ -44,13 +44,13 @@ def get_engine_url(): # ... etc. -def get_metadata(): +def get_metadata() -> target_db: if hasattr(target_db, "metadatas"): return target_db.metadatas[None] return target_db.metadata -def run_migrations_offline(): +def run_migrations_offline() -> None: """Run migrations in 'offline' mode. This configures the context with just a URL @@ -70,7 +70,7 @@ def run_migrations_offline(): context.run_migrations() -def run_migrations_online(): +def run_migrations_online() -> None: """Run migrations in 'online' mode. In this scenario we need to create an Engine @@ -81,7 +81,7 @@ def run_migrations_online(): # this callback is used to prevent an auto-migration from being generated # when there are no changes to the schema # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html - def process_revision_directives(context, revision, directives): + def process_revision_directives(context, revision, directives) -> None: if getattr(config.cmd_opts, "autogenerate", False): script = directives[0] if script.upgrade_ops.is_empty():