refactor: improve code readability by formatting arguments across multiple files
Test / test (push) Successful in 15s

This commit is contained in:
Artem Kashaev
2025-12-01 16:25:30 +05:00
parent dc0046c730
commit 1dd7c2f2b8
22 changed files with 161 additions and 49 deletions
+11 -3
View File
@@ -46,7 +46,9 @@ class RedisCacheManager:
if self._client is not None:
return
self._client = redis.from_url(
settings.redis_url, encoding="utf-8", decode_responses=False,
settings.redis_url,
encoding="utf-8",
decode_responses=False,
)
await self._refresh_availability()
@@ -63,7 +65,9 @@ class RedisCacheManager:
async with self._lock:
if self._client is None:
self._client = redis.from_url(
settings.redis_url, encoding="utf-8", decode_responses=False,
settings.redis_url,
encoding="utf-8",
decode_responses=False,
)
await self._refresh_availability()
@@ -127,7 +131,11 @@ async def read_json(client: Redis, key: str) -> Any | None:
async def write_json(
client: Redis, key: str, value: Any, ttl_seconds: int, backoff_ms: int,
client: Redis,
key: str,
value: Any,
ttl_seconds: int,
backoff_ms: int,
) -> None:
"""Serialize data to JSON and store it with TTL using retry/backoff."""
payload = json.dumps(value, separators=(",", ":"), ensure_ascii=True).encode("utf-8")
+5 -2
View File
@@ -17,7 +17,8 @@ class Settings(BaseSettings):
db_name: str = Field(default="test_task_crm", description="Database name")
db_user: str = Field(default="postgres", description="Database user")
db_password: SecretStr = Field(
default=SecretStr("postgres"), description="Database user password",
default=SecretStr("postgres"),
description="Database user password",
)
database_url_override: str | None = Field(
default=None,
@@ -32,7 +33,9 @@ class Settings(BaseSettings):
redis_enabled: bool = Field(default=False, description="Toggle Redis-backed cache usage")
redis_url: str = Field(default="redis://localhost:6379/0", description="Redis connection URL")
analytics_cache_ttl_seconds: int = Field(
default=120, ge=1, description="TTL for cached analytics responses",
default=120,
ge=1,
description="TTL for cached analytics responses",
)
analytics_cache_backoff_ms: int = Field(
default=200,