Skip to content

Commit 989947e

Browse files
📝 Add docstrings to codex/add-lru_cache-for-get_settings-helper (#38)
Docstrings generation was requested by @shayancoin. * #23 (comment) The following files were modified: * `backend/api/config.py` * `backend/api/routes_sync.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent c9efcdd commit 989947e

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

backend/api/config.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,32 @@ class Settings(BaseSettings):
4848

4949
@lru_cache()
5050
def get_settings() -> Settings:
51-
"""Return a cached instance of :class:`Settings`."""
51+
"""
52+
Provide the application Settings instance and reuse the same instance across calls.
53+
54+
Returns:
55+
Settings: The Settings instance loaded from environment variables; subsequent calls return the cached same instance.
56+
"""
5257

5358
return Settings()
5459

5560

5661
def get_fastapi_settings() -> Dict[str, Any]:
57-
"""Get FastAPI application settings.
58-
59-
Returns
60-
-------
61-
Dict[str, Any]
62-
Dictionary with FastAPI settings.
62+
"""
63+
Provide FastAPI application metadata and routing configuration for documentation UIs.
64+
65+
Returns:
66+
fastapi_settings (Dict[str, Any]): Mapping containing:
67+
- title: API display title.
68+
- description: Short API description.
69+
- version: API semantic version string.
70+
- docs_url: URL path for the Swagger UI.
71+
- redoc_url: URL path for the ReDoc UI.
6372
"""
6473
return {
6574
"title": "MVP API",
6675
"description": "API for MVP application",
6776
"version": "0.1.0",
6877
"docs_url": "/docs",
6978
"redoc_url": "/redoc",
70-
}
79+
}

backend/api/routes_sync.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,26 @@
3939

4040

4141
def get_hygraph_service() -> HygraphService:
42-
"""Provide the shared Hygraph service instance."""
42+
"""
43+
Provide the module-level shared HygraphService singleton.
44+
45+
Returns:
46+
HygraphService: The shared HygraphService instance.
47+
"""
4348

4449
return _hygraph_service
4550
def _error_envelope(code: str, message: str, details: Optional[dict] = None) -> Dict[str, Any]:
51+
"""
52+
Builds a standardized error envelope for API responses.
53+
54+
Parameters:
55+
code (str): Machine-readable error code identifying the error.
56+
message (str): Human-readable error message describing the failure.
57+
details (Optional[dict]): Additional contextual information; defaults to an empty dict when not provided.
58+
59+
Returns:
60+
Dict[str, Any]: Dictionary with keys `ok` (False) and `error` containing `code`, `message`, and `details`.
61+
"""
4662
return {"ok": False, "error": {"code": code, "message": message, "details": details or {}}}
4763

4864

0 commit comments

Comments
 (0)