Skip to content

Commit

Permalink
changes SimpleNamespace to NamedTuple
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Sep 25, 2024
1 parent 3bdef46 commit 71ae90c
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions aim/services.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 71ae90c

Please sign in to comment.