Make mypy work again #8

Merged
alexander merged 16 commits from fix-mypy into develop 2026-11-30 14:13:44 +01:00
Showing only changes of commit a320c1fba5 - Show all commits

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
Alexander Hess 2026-11-30 11:34:26 +01:00
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

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