Skip to content

Commit

Permalink
dotenv fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Jul 11, 2021
1 parent 20a47ef commit 0683d64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."""

__version__ = "0.2.2"
__version__ = "0.2.3"

from abc import ABC

Expand Down
6 changes: 5 additions & 1 deletion fractal/core/utils/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from io import StringIO

from dotenv import load_dotenv
Expand All @@ -10,7 +11,10 @@ def __new__(cls, dotenv=True, *args, **kwargs):
if not isinstance(cls.instance, cls):
cls.instance = object.__new__(cls, *args, **kwargs)
if dotenv:
load_dotenv()
dotenv_path = None
if root_dir := getattr(cls, "ROOT_DIR", None):
dotenv_path = os.path.join(root_dir, ".env")
load_dotenv(dotenv_path)
cls.instance.load()
return cls.instance

Expand Down

0 comments on commit 0683d64

Please sign in to comment.