Fix ModuleNotFoundError for pydantic_settings
- Added pydantic and pydantic-settings to requirements.txt - Updated config.py to use proper Pydantic v2 imports and patterns - Updated schemas to use Pydantic v2 configuration format - Replaced orm_mode with from_attributes=True in schema models - Applied code formatting with Ruff
This commit is contained in:
parent
9bfdefc0b4
commit
aaac87335a
@ -1,6 +1,6 @@
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
@ -20,9 +20,7 @@ class Settings(BaseSettings):
|
||||
# Configure max file size (10MB by default)
|
||||
MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB in bytes
|
||||
|
||||
class Config:
|
||||
case_sensitive = True
|
||||
env_file = ".env"
|
||||
model_config = SettingsConfigDict(case_sensitive=True, env_file=".env")
|
||||
|
||||
|
||||
# Create settings instance
|
||||
|
@ -14,6 +14,7 @@ sys.path.insert(0, str(current_path))
|
||||
|
||||
# Import Base after setting up sys.path
|
||||
from app.db.base import Base # noqa: E402
|
||||
|
||||
# Import all models to register them with SQLAlchemy metadata
|
||||
from app.models.file import File # noqa: E402, F401 - import needed for Alembic to detect models
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class FileBase(BaseModel):
|
||||
@ -25,8 +25,7 @@ class FileInDB(FileBase):
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class FileResponse(FileBase):
|
||||
@ -37,5 +36,4 @@ class FileResponse(FileBase):
|
||||
created_at: datetime
|
||||
download_url: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
@ -4,4 +4,6 @@ sqlalchemy>=2.0.0
|
||||
alembic>=1.10.0
|
||||
python-multipart>=0.0.6
|
||||
python-dotenv>=1.0.0
|
||||
pydantic>=2.0.0
|
||||
pydantic-settings>=2.0.0
|
||||
ruff>=0.1.0
|
Loading…
x
Reference in New Issue
Block a user