@1mancompany/onemancompany 0.7.55 → 0.7.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/src/onemancompany/core/config.py +10 -1
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -595,7 +595,13 @@ settings = Settings()
|
|
|
595
595
|
|
|
596
596
|
|
|
597
597
|
def update_env_var(key: str, value: str) -> None:
|
|
598
|
-
"""Update or add a variable in the .env file, then reload settings.
|
|
598
|
+
"""Update or add a variable in the .env file, then reload settings.
|
|
599
|
+
|
|
600
|
+
Also syncs os.environ so that pydantic BaseSettings (which reads os.environ
|
|
601
|
+
with higher priority than .env files) sees the new value immediately.
|
|
602
|
+
"""
|
|
603
|
+
import os as _os
|
|
604
|
+
|
|
599
605
|
env_path = DATA_ROOT / DOT_ENV_FILENAME
|
|
600
606
|
lines: list[str] = []
|
|
601
607
|
found = False
|
|
@@ -610,6 +616,9 @@ def update_env_var(key: str, value: str) -> None:
|
|
|
610
616
|
if not found:
|
|
611
617
|
lines.append(f"{key}={value}")
|
|
612
618
|
env_path.write_text("\n".join(lines) + "\n", encoding=ENCODING_UTF8)
|
|
619
|
+
# Sync os.environ — main.py's load_dotenv() seeds it at startup;
|
|
620
|
+
# without this, the stale env var wins over the updated .env file.
|
|
621
|
+
_os.environ[key] = value
|
|
613
622
|
reload_settings()
|
|
614
623
|
|
|
615
624
|
|