Make mypy work again #8
1 changed files with 6 additions and 5 deletions
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
commit
a320c1fba5
|
|
@ -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)()
|
||||
|
|
|
|||
Loading…
Reference in a new issue