Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore extra settings #1010

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions src/marvin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Settings(BaseSettings):
case_sensitive=False,
env_file=".env",
env_file_encoding="utf-8",
extra="forbid",
extra="ignore",
validate_assignment=True,
)

Expand All @@ -48,26 +48,13 @@ def validate_home_path(cls, v: Path) -> Path:
@model_validator(mode="after")
def validate_database_url(self) -> Self:
"""Set and validate the database path."""
# Set default if not provided
if self.database_url is None:
self.__dict__["database_url"] = str(self.home_path / "marvin.db")
return self
if self.database_path is None:
self.database_path = self.home_path / "marvin.db"
else:
if not self.database_path.is_absolute():
self.database_path = Path.cwd() / self.database_path

# Handle in-memory database
if self.database_url == ":memory:":
return self

# Convert to Path for validation
path = Path(self.database_url)

# Expand user and resolve to absolute path
path = path.expanduser().resolve()

# Ensure parent directory exists
path.parent.mkdir(parents=True, exist_ok=True)

# Store result as string
self.__dict__["database_url"] = str(path)
self.database_path.parent.mkdir(parents=True, exist_ok=True)

return self

Expand Down
Loading