Skip to content

Commit

Permalink
Add types of settings for static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Jan 23, 2024
1 parent 5c47826 commit fdd1577
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion hera_librarian/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from pydantic import BaseModel
from pydantic_settings import BaseSettings

from typing import TYPE_CHECKING

if TYPE_CHECKING:
client_settings: "ClientSettings"


class ClientInfo(BaseModel):
"""
Expand Down Expand Up @@ -39,12 +44,17 @@ def load_settings() -> ClientSettings:
global _settings

try_paths = [
Path(os.environ["HL_CLIENT_CONFIG"]),
os.environ.get("HL_CLIENT_CONFIG", None),
Path.home() / ".hl_client.cfg",
Path.home() / ".hl_client.json",
]

for path in try_paths:
if path is not None:
path = Path(path)
else:
continue

if path.exists():
_settings = ClientSettings.from_file(path)
return _settings
Expand Down
12 changes: 11 additions & 1 deletion librarian_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

from .stores import StoreNames

from typing import TYPE_CHECKING

if TYPE_CHECKING:
server_settings: "ServerSettings"


class StoreSettings(BaseModel):
"""
Expand Down Expand Up @@ -87,10 +92,15 @@ def load_settings() -> ServerSettings:
global _settings

try_paths = [
Path(os.environ["LIBRARIAN_CONFIG_PATH"]),
os.environ.get("LIBRARIAN_CONFIG_PATH", None),
]

for path in try_paths:
if path is not None:
path = Path(path)
else:
continue

if path.exists():
_settings = ServerSettings.from_file(path)
return _settings
Expand Down

0 comments on commit fdd1577

Please sign in to comment.