From 71ae90c1f219669b3218028fe4c23e5421420ce7 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Wed, 25 Sep 2024 22:08:21 +0000 Subject: [PATCH] changes SimpleNamespace to NamedTuple --- aim/services.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/aim/services.py b/aim/services.py index 0525bbb..b3893d1 100644 --- a/aim/services.py +++ b/aim/services.py @@ -1,15 +1,39 @@ from types import SimpleNamespace +from typing import NamedTuple import os import sqlalchemy as sa -S = SimpleNamespace() -S.mysql_database = sa.engine.URL.create( - drivername="mysql+mysqldb", - username=os.environ["MARIADB_USER"], - password=os.environ["MARIADB_PASSWORD"], - host=os.environ["DATABASE_HOST"], - database=os.environ["MARIADB_DATABASE"], +Services = NamedTuple( + "Services", + [ + ("mysql_database", sa.engine.URL), + ("test_database", str), + ("ci_on", str | None), + ("digifeeds_api_url", str), + ], ) -S.test_database = "sqlite:///:memory:" -S.ci_on = os.getenv("CI") -S.digifeeds_api_url = os.getenv("DIGIFEEDS_API_URL") or "http://api:8000" + +S = Services( + mysql_database=sa.engine.URL.create( + drivername="mysql+mysqldb", + username=os.environ["MARIADB_USER"], + password=os.environ["MARIADB_PASSWORD"], + host=os.environ["DATABASE_HOST"], + database=os.environ["MARIADB_DATABASE"], + ), + test_database="sqlite:///:memory:", + ci_on=os.getenv("CI"), + digifeeds_api_url=os.getenv("DIGIFEEDS_API_URL") or "http://api:8000", +) + +# S = SimpleNamespace() +# S.mysql_database = sa.engine.URL.create( +# drivername="mysql+mysqldb", +# username=os.environ["MARIADB_USER"], +# password=os.environ["MARIADB_PASSWORD"], +# host=os.environ["DATABASE_HOST"], +# database=os.environ["MARIADB_DATABASE"], +# ) +# S.test_database = "sqlite:///:memory:" +# S.ci_on = os.getenv("CI") +# S.digifeeds_api_url = os.getenv("DIGIFEEDS_API_URL") or "http://api:8000"