Skip to content

Commit 66c61fa

Browse files
author
Bryan Sieber
committed
Issue #12
1 parent 88d88fa commit 66c61fa

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/app/environment.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
Module dedicated to interacting with the environment (variables, version.json)
33
"""
44
import json
5-
import os
65
from functools import lru_cache
6+
from pathlib import Path
77

88
from pydantic import BaseSettings
99

1010

1111
class Settings(BaseSettings):
12-
"""
13-
The Settings object extracts environment variables for convenience
14-
"""
12+
"""The Settings object extracts environment variables for convenience."""
1513

1614
host: str = "0.0.0.0"
1715
port: str = "80"
@@ -33,9 +31,7 @@ class Settings(BaseSettings):
3331

3432
@lru_cache()
3533
def get_settings() -> Settings:
36-
"""
37-
Return the Settings object; use cache
38-
"""
34+
"""Return the Settings object; use cache"""
3935
return Settings()
4036

4137

@@ -45,10 +41,9 @@ def get_version():
4541
Return contents of version.json.
4642
This has generic data in repo, but gets the build details in CI.
4743
"""
48-
_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
49-
version_path = os.path.join(_root, "version.json")
5044
info = {}
51-
if os.path.exists(version_path):
52-
with open(version_path, "r", encoding="utf8") as version_file:
53-
info = json.load(version_file)
45+
version_path = Path(__file__).parents[2] / "version.json"
46+
print(version_path)
47+
if version_path.exists():
48+
info = json.loads(version_path.read_text(encoding="utf8"))
5449
return info

0 commit comments

Comments
 (0)