Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
madnoberson committed Jan 22, 2024
1 parent 64897b7 commit 5a18609
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/amdb/infrastructure/persistence/alembic/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ def get_env(key: str) -> str:


def get_sqlalchemy_url() -> str:
if not config.get_main_option("sqlalchemy.url"):
sqlalchemy_url = config.get_main_option("sqlalchemy.url")
if sqlalchemy_url is not None:
return sqlalchemy_url
else:
host = get_env(POSTGRES_HOST_ENV)
port = get_env(POSTGRES_PORT_ENV)
name = get_env(POSTGRES_NAME_ENV)
user = get_env(POSTGRES_USER_ENV)
password = get_env(POSTGRES_PASSWORD_ENV)

return f"postgresql://{user}:{password}@{host}:{port}/{name}"
else:
return config.get_main_option("sqlalchemy.url")


def run_migrations_offline() -> None:
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/infrastructure/alembic/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterator

import pytest
import alembic.config
import psycopg2
Expand All @@ -13,7 +15,7 @@ def alembic_config(postgres_url: str) -> alembic.config.Config:


@pytest.fixture(scope="package", autouse=True)
def clear_database(postgres_url: str) -> None:
def clear_database(postgres_url: str) -> Iterator[None]:
connection = psycopg2.connect(postgres_url)
cursor = connection.cursor()

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/infrastructure/alembic/test_stairway.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def test_migrations_stairway(alembic_config: alembic.config.Config):
alembic.command.upgrade(alembic_config, revision.revision)

# We need -1 for downgrading first migration (its down_revision is None)
alembic.command.downgrade(alembic_config, revision.down_revision or "-1")
alembic.command.downgrade(alembic_config, revision.down_revision or "-1") # type: ignore
alembic.command.upgrade(alembic_config, revision.revision)

0 comments on commit 5a18609

Please sign in to comment.