fix: add missing commas for syntax correctness across multiple files
Test / test (push) Successful in 15s

This commit is contained in:
Artem Kashaev
2025-12-01 16:19:19 +05:00
parent ed6c656963
commit 1039fba571
23 changed files with 52 additions and 52 deletions
+1 -1
View File
@@ -95,5 +95,5 @@ async def deals_funnel(
breakdowns: list[StageBreakdown] = await service.get_deal_funnel(context.organization_id)
return DealFunnelResponse(
stages=[StageBreakdownModel.model_validate(item) for item in breakdowns]
stages=[StageBreakdownModel.model_validate(item) for item in breakdowns],
)
+1 -1
View File
@@ -83,7 +83,7 @@ async def create_contact(
service: ContactService = Depends(get_contact_service),
) -> ContactRead:
data = payload.to_domain(
organization_id=context.organization_id, fallback_owner=context.user_id
organization_id=context.organization_id, fallback_owner=context.user_id,
)
try:
contact = await service.create_contact(data, context=context)
+2 -2
View File
@@ -68,7 +68,7 @@ async def list_deals(
stage_value = DealStage(stage) if stage else None
except ValueError as exc:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid deal filter"
status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid deal filter",
) from exc
params = DealQueryParams(
@@ -100,7 +100,7 @@ async def create_deal(
"""Create a new deal within the current organization."""
data = payload.to_domain(
organization_id=context.organization_id, fallback_owner=context.user_id
organization_id=context.organization_id, fallback_owner=context.user_id,
)
try:
deal = await service.create_deal(data, context=context)
+3 -3
View File
@@ -46,7 +46,7 @@ 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 +63,7 @@ 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 +127,7 @@ 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")
+2 -2
View File
@@ -17,7 +17,7 @@ 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 +32,7 @@ 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,
+1 -1
View File
@@ -38,7 +38,7 @@ class User(Base):
)
memberships = relationship(
"OrganizationMember", back_populates="user", cascade="all, delete-orphan"
"OrganizationMember", back_populates="user", cascade="all, delete-orphan",
)
owned_contacts = relationship("Contact", back_populates="owner")
owned_deals = relationship("Deal", back_populates="owner")
+1 -1
View File
@@ -41,7 +41,7 @@ class ActivityRepository:
select(Activity)
.join(Deal, Deal.id == Activity.deal_id)
.where(
Activity.deal_id == params.deal_id, Deal.organization_id == params.organization_id
Activity.deal_id == params.deal_id, Deal.organization_id == params.organization_id,
)
.order_by(Activity.created_at)
)
+2 -2
View File
@@ -46,7 +46,7 @@ class ContactRepository:
user_id: int,
) -> Sequence[Contact]:
stmt: Select[tuple[Contact]] = select(Contact).where(
Contact.organization_id == params.organization_id
Contact.organization_id == params.organization_id,
)
stmt = self._apply_filters(stmt, params, role, user_id)
offset = (max(params.page, 1) - 1) * params.page_size
@@ -63,7 +63,7 @@ class ContactRepository:
user_id: int,
) -> Contact | None:
stmt = select(Contact).where(
Contact.id == contact_id, Contact.organization_id == organization_id
Contact.id == contact_id, Contact.organization_id == organization_id,
)
result = await self._session.scalars(stmt)
return result.first()
+1 -1
View File
@@ -148,7 +148,7 @@ class DealRepository:
return stmt
def _apply_ordering(
self, stmt: Select[tuple[Deal]], params: DealQueryParams
self, stmt: Select[tuple[Deal]], params: DealQueryParams,
) -> Select[tuple[Deal]]:
column = ORDERABLE_COLUMNS.get(params.order_by or "created_at", Deal.created_at)
order_func = desc if params.order_desc else asc
+1 -1
View File
@@ -107,7 +107,7 @@ class TaskRepository:
return task
def _apply_filters(
self, stmt: Select[tuple[Task]], params: TaskQueryParams
self, stmt: Select[tuple[Task]], params: TaskQueryParams,
) -> Select[tuple[Task]]:
if params.deal_id is not None:
stmt = stmt.where(Task.deal_id == params.deal_id)
+3 -3
View File
@@ -169,7 +169,7 @@ class AnalyticsService:
return _deserialize_summary(payload)
async def _store_summary_cache(
self, organization_id: int, days: int, summary: DealSummary
self, organization_id: int, days: int, summary: DealSummary,
) -> None:
if not self._is_cache_enabled() or self._cache is None:
return
@@ -187,7 +187,7 @@ class AnalyticsService:
return _deserialize_funnel(payload)
async def _store_funnel_cache(
self, organization_id: int, breakdowns: list[StageBreakdown]
self, organization_id: int, breakdowns: list[StageBreakdown],
) -> None:
if not self._is_cache_enabled() or self._cache is None:
return
@@ -321,7 +321,7 @@ def _deserialize_funnel(payload: Any) -> list[StageBreakdown] | None:
async def invalidate_analytics_cache(
cache: Redis | None, organization_id: int, backoff_ms: int
cache: Redis | None, organization_id: int, backoff_ms: int,
) -> None:
"""Remove cached analytics payloads for the organization."""
+2 -2
View File
@@ -80,7 +80,7 @@ class ContactService:
)
try:
return await self._repository.list(
params=params, role=context.role, user_id=context.user_id
params=params, role=context.role, user_id=context.user_id,
)
except ContactAccessError as exc:
raise ContactForbiddenError(str(exc)) from exc
@@ -126,7 +126,7 @@ class ContactService:
return contact
try:
return await self._repository.update(
contact, payload, role=context.role, user_id=context.user_id
contact, payload, role=context.role, user_id=context.user_id,
)
except ContactAccessError as exc:
raise ContactForbiddenError(str(exc)) from exc
+6 -6
View File
@@ -79,7 +79,7 @@ class DealService:
await self._ensure_contact_in_organization(data.contact_id, context.organization_id)
deal = await self._repository.create(data=data, role=context.role, user_id=context.user_id)
await invalidate_analytics_cache(
self._cache, context.organization_id, self._cache_backoff_ms
self._cache, context.organization_id, self._cache_backoff_ms,
)
return deal
@@ -120,7 +120,7 @@ class DealService:
return deal
updated = await self._repository.update(
deal, changes, role=context.role, user_id=context.user_id
deal, changes, role=context.role, user_id=context.user_id,
)
await self._log_activities(
deal_id=deal.id,
@@ -128,7 +128,7 @@ class DealService:
activities=[activity for activity in [stage_activity, status_activity] if activity],
)
await invalidate_analytics_cache(
self._cache, context.organization_id, self._cache_backoff_ms
self._cache, context.organization_id, self._cache_backoff_ms,
)
return updated
@@ -150,7 +150,7 @@ class DealService:
return
for activity_type, payload in entries:
activity = Activity(
deal_id=deal_id, author_id=author_id, type=activity_type, payload=payload
deal_id=deal_id, author_id=author_id, type=activity_type, payload=payload,
)
self._repository.session.add(activity)
await self._repository.session.flush()
@@ -160,7 +160,7 @@ class DealService:
raise DealOrganizationMismatchError("Operation targets a different organization")
async def _ensure_contact_in_organization(
self, contact_id: int, organization_id: int
self, contact_id: int, organization_id: int,
) -> Contact:
contact = await self._repository.session.get(Contact, contact_id)
if contact is None or contact.organization_id != organization_id:
@@ -185,5 +185,5 @@ class DealService:
effective_amount = updates.amount if updates.amount is not None else deal.amount
if effective_amount is None or Decimal(effective_amount) <= Decimal("0"):
raise DealStatusValidationError(
"Amount must be greater than zero to mark a deal as won"
"Amount must be greater than zero to mark a deal as won",
)
+2 -2
View File
@@ -56,7 +56,7 @@ class OrganizationService:
self._repository = repository
async def get_context(
self, *, user_id: int, organization_id: int | None
self, *, user_id: int, organization_id: int | None,
) -> OrganizationContext:
"""Resolve request context ensuring the user belongs to the given organization."""
@@ -70,7 +70,7 @@ class OrganizationService:
return OrganizationContext(organization=membership.organization, membership=membership)
def ensure_entity_in_context(
self, *, entity_organization_id: int, context: OrganizationContext
self, *, entity_organization_id: int, context: OrganizationContext,
) -> None:
"""Make sure a resource belongs to the current organization."""