- Reformatted function signatures in `organization_service.py` and `task_service.py` for better alignment. - Updated import statements across multiple files for consistency and organization. - Enhanced test files by improving formatting and ensuring consistent use of async session factories. - Added type hints and improved type safety in various service and test files. - Adjusted `pyproject.toml` to include configuration for isort, mypy, and ruff for better code quality checks. - Cleaned up unused imports and organized existing ones in several test files.
This commit is contained in:
+12
-5
@@ -1,4 +1,5 @@
|
||||
"""Activity timeline ORM model and schemas."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
@@ -6,10 +7,12 @@ from enum import StrEnum
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from sqlalchemy import DateTime, Enum as SqlEnum, ForeignKey, Integer, func, text
|
||||
from sqlalchemy import DateTime, ForeignKey, Integer, func, text
|
||||
from sqlalchemy import Enum as SqlEnum
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.types import JSON as GenericJSON, TypeDecorator
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.types import JSON as GenericJSON
|
||||
from sqlalchemy.types import TypeDecorator
|
||||
|
||||
from app.models.base import Base, enum_values
|
||||
|
||||
@@ -44,10 +47,12 @@ class Activity(Base):
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
deal_id: Mapped[int] = mapped_column(ForeignKey("deals.id", ondelete="CASCADE"))
|
||||
author_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
|
||||
ForeignKey("users.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
)
|
||||
type: Mapped[ActivityType] = mapped_column(
|
||||
SqlEnum(ActivityType, name="activity_type", values_callable=enum_values), nullable=False
|
||||
SqlEnum(ActivityType, name="activity_type", values_callable=enum_values),
|
||||
nullable=False,
|
||||
)
|
||||
payload: Mapped[dict[str, Any]] = mapped_column(
|
||||
JSONBCompat().with_variant(GenericJSON(), "sqlite"),
|
||||
@@ -55,7 +60,9 @@ class Activity(Base):
|
||||
server_default=text("'{}'"),
|
||||
)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now(), nullable=False
|
||||
DateTime(timezone=True),
|
||||
server_default=func.now(),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
deal = relationship("Deal", back_populates="activities")
|
||||
|
||||
Reference in New Issue
Block a user