Skip to content

Commit

Permalink
fix: load dotenv before config import (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell committed Apr 30, 2024
1 parent aee7ede commit ba2ea8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 6 additions & 3 deletions secator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

import requests
import yaml
from dotenv import find_dotenv, load_dotenv
from dotmap import DotMap
from pydantic import AfterValidator, BaseModel, model_validator, ValidationError

from secator.rich import console, console_stdout

load_dotenv(find_dotenv(usecwd=True), override=False)

Directory = Annotated[Path, AfterValidator(lambda v: v.expanduser())]
StrExpandHome = Annotated[str, AfterValidator(lambda v: v.replace('~', str(Path.home())))]

Expand Down Expand Up @@ -245,9 +248,9 @@ def set(self, key, value, set_partial=True):
value = float(value)
elif isinstance(existing_value, Path):
value = Path(value)
except ValueError as e:
from secator.utils import debug
debug(f'Could not cast value {value} to expected type {type(existing_value).__name__}: {str(e)}', sub='config')
except ValueError:
# from secator.utils import debug
# debug(f'Could not cast value {value} to expected type {type(existing_value).__name__}: {str(e)}', sub='config')
pass
finally:
target[final_key] = value
Expand Down
2 changes: 0 additions & 2 deletions secator/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import os

from dotenv import find_dotenv, load_dotenv
from importlib.metadata import version

from secator.config import CONFIG, ROOT_FOLDER

load_dotenv(find_dotenv(usecwd=True), override=False)

# Globals
VERSION = version('secator')
Expand Down

0 comments on commit ba2ea8e

Please sign in to comment.