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:
parent
b5a6fb42cc
commit
a320c1fba5
1 changed files with 6 additions and 5 deletions
|
|
@ -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)()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue