Type the database placeholders for mypy

The test fixtures replace the `None` placeholders, and `velofy.configuration` already ensures that "DATABASE_URI" is set outside of tests
This commit is contained in:
Alexander Hess 2026-11-30 11:34:26 +01:00
commit a320c1fba5
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -8,6 +8,7 @@ That is the case on the CI server.
""" """
import os import os
from typing import cast
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import engine as engine_mod from sqlalchemy import engine as engine_mod
@ -17,12 +18,12 @@ import velofy
if os.getenv("TESTING"): if os.getenv("TESTING"):
# Specify the types explicitly to make mypy happy. # Placeholders that the test fixtures replace
engine: engine_mod.Engine = None engine: engine_mod.Engine = None # type: ignore[assignment]
connection: engine_mod.Connection = None connection: engine_mod.Connection = None # type: ignore[assignment]
session: orm.Session = None session: orm.Session = None # type: ignore[assignment]
else: # pragma: no cover else: # pragma: no cover
engine = sa.create_engine(velofy.config.DATABASE_URI) engine = sa.create_engine(cast(str, velofy.config.DATABASE_URI))
connection = engine.connect() connection = engine.connect()
session = orm.sessionmaker(bind=connection)() session = orm.sessionmaker(bind=connection)()