Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(mypy): Enforcing typing for superset.migrations module #9583

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ order_by_type = false
ignore_missing_imports = true
no_implicit_optional = true

[mypy-superset.bin.*,superset.charts.*,superset.datasets.*,superset.dashboards.*,superset.commands.*,superset.common.*,superset.dao.*,superset.db_engine_specs.*,superset.db_engines.*,superset.examples.*]
[mypy-superset.bin.*,superset.charts.*,superset.datasets.*,superset.dashboards.*,superset.commands.*,superset.common.*,superset.dao.*,superset.db_engine_specs.*,superset.db_engines.*,superset.examples.*,superset.migrations.*]
check_untyped_defs = true
disallow_untyped_calls = true
disallow_untyped_defs = true
13 changes: 8 additions & 5 deletions superset/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
# under the License.
import logging
from logging.config import fileConfig
from typing import List

from alembic import context
from alembic.operations.ops import MigrationScript
from alembic.runtime.migration import MigrationContext
from flask import current_app
from flask_appbuilder import Base
from sqlalchemy import engine_from_config, pool
Expand All @@ -41,7 +44,7 @@
# ... etc.


def run_migrations_offline():
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.

This configures the context with just a URL
Expand All @@ -60,7 +63,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
Expand All @@ -71,9 +74,9 @@ 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: https://alembic.sqlalchemy.org/en/latest/cookbook.html
def process_revision_directives(
context, revision, directives
): # pylint: disable=redefined-outer-name, unused-argument
def process_revision_directives( # pylint: disable=redefined-outer-name, unused-argument
context: MigrationContext, revision: str, directives: List[MigrationScript]
) -> None:
if getattr(config.cmd_opts, "autogenerate", False):
script = directives[0]
if script.upgrade_ops.is_empty():
Expand Down