Skip to content

Commit

Permalink
Update config in settings.py to newest pydantic requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Afonso-2403 committed Oct 24, 2023
1 parent 38764dd commit 39e89e5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/isar_exr/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@

from dotenv import load_dotenv
from pydantic import Field
from pydantic_settings import BaseSettings
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
def __init__(self) -> None:
try:
with pkg_resources.path(f"isar_exr.config", "settings.env") as path:
env_file_path = path
except ModuleNotFoundError:
env_file_path = None
super().__init__(_env_file=env_file_path)

# The ID of the robot in the EXR database
ROBOT_EXR_ID: str = Field(default="61a09ebc5f71911c10b463ce")

Expand Down Expand Up @@ -36,14 +44,11 @@ class Settings(BaseSettings):
"../../../docs/schema.graphql"
)

class Config:
with pkg_resources.path("isar_exr.config", "settings.env") as path:
package_path = path

env_prefix = "EXR_"
env_file = package_path
env_file_encoding = "utf-8"
case_sensitive = True
model_config = SettingsConfigDict(
env_prefix="EXR_",
env_file_encoding="utf-8",
case_sensitive=True,
)


load_dotenv()
Expand Down

0 comments on commit 39e89e5

Please sign in to comment.