smoothed readme and startup

This commit is contained in:
John Lancaster
2026-08-01 09:51:21 -05:00
parent d75083a666
commit 661e2b1bec
4 changed files with 87 additions and 20 deletions
+4 -3
View File
@@ -52,6 +52,7 @@ class Settings(BaseSettings):
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
env_nested_delimiter="__",
cli_implicit_flags=True,
cli_kebab_case=True,
)
@@ -92,7 +93,7 @@ class Settings(BaseSettings):
@property
def should_bootstrap_schema(self) -> bool:
"""Return whether startup should auto-create schema for this environment."""
if self.bootstrap_schema_on_startup is not None:
if "bootstrap_schema_on_startup" in self.model_fields_set:
return self.bootstrap_schema_on_startup
return self.environment in {"development", "test"}
@@ -100,13 +101,13 @@ class Settings(BaseSettings):
@cache
def get_settings(**kwargs: Any) -> Settings:
"""Load cached settings without reading process CLI arguments."""
return Settings(_cli_parse_args=False, **kwargs)
return Settings(_cli_parse_args=False, **kwargs) # pyright: ignore[reportCallIssue]
def parse_cli_settings(args: Sequence[str] | None = None) -> Settings:
"""Load settings with CLI arguments at the executable boundary."""
cli_args = True if args is None else list(args)
return Settings(_cli_parse_args=cli_args)
return Settings(_cli_parse_args=cli_args) # pyright: ignore[reportCallIssue]
LOGGING_CONFIG: dict[str, Any] = {
+7 -3
View File
@@ -31,8 +31,9 @@ def resolve_session_factory(
*,
settings: Settings | None = None,
) -> SessionFactory:
active_settings = settings or get_settings()
return get_session_factory(database_url or get_database_url(active_settings))
if database_url is not None:
return get_session_factory(database_url)
return get_session_factory(get_database_url(settings or get_settings()))
type SessionFactoryDep = Annotated[SessionFactory, Depends(resolve_session_factory)]
@@ -92,4 +93,7 @@ async def transaction_scope(
yield owned_session
type TransactionScopeDep = Annotated[AsyncSessionTransaction, Depends(transaction_scope)]
type TransactionScopeDep = Annotated[
AsyncSession | AsyncSessionTransaction,
Depends(transaction_scope),
]