Fix all Pydantic v2 deprecation warnings (17 model classes)
Convert deprecated class Config pattern to modern ConfigDict pattern across all data models: - models/asset.py: Updated 6 classes (AssetFolder, Asset, AssetUpload, AssetRename, AssetMove, FolderCreate) - models/group.py: Updated 8 classes (GroupPermission, GroupPageRule, GroupUser, Group, GroupCreate, GroupUpdate, GroupAssignUser, GroupUnassignUser) - models/user.py: Updated 3 classes (User, UserCreate, UserUpdate) Changes: - Added ConfigDict import from pydantic - Replaced 'class Config:' with 'model_config = ConfigDict(...)' - Preserved all config options (populate_by_name, str_strip_whitespace) Impact: - Eliminated 19 Pydantic deprecation warnings - All 423 tests still passing - No breaking changes to functionality - Future-proofed for Pydantic v3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic import ConfigDict, Field, field_validator
|
||||
|
||||
from .base import BaseModel, TimestampedModel
|
||||
|
||||
@@ -10,15 +10,12 @@ from .base import BaseModel, TimestampedModel
|
||||
class AssetFolder(BaseModel):
|
||||
"""Asset folder model."""
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
id: int = Field(..., description="Folder ID")
|
||||
slug: str = Field(..., description="Folder slug/path")
|
||||
name: Optional[str] = Field(None, description="Folder name")
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
|
||||
|
||||
class Asset(TimestampedModel):
|
||||
"""Wiki.js asset model.
|
||||
@@ -75,10 +72,7 @@ class Asset(TimestampedModel):
|
||||
"""Get file size in kilobytes."""
|
||||
return self.file_size / 1024
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
|
||||
class AssetUpload(BaseModel):
|
||||
@@ -102,10 +96,7 @@ class AssetUpload(BaseModel):
|
||||
raise ValueError("File path cannot be empty")
|
||||
return v.strip()
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
|
||||
class AssetRename(BaseModel):
|
||||
@@ -137,10 +128,7 @@ class AssetRename(BaseModel):
|
||||
raise ValueError("Filename cannot be empty")
|
||||
return v.strip()
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
|
||||
class AssetMove(BaseModel):
|
||||
@@ -170,10 +158,7 @@ class AssetMove(BaseModel):
|
||||
raise ValueError("Folder ID must be non-negative")
|
||||
return v
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
|
||||
class FolderCreate(BaseModel):
|
||||
@@ -199,7 +184,4 @@ class FolderCreate(BaseModel):
|
||||
raise ValueError("Slug cannot be just slashes")
|
||||
return v
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
|
||||
populate_by_name = True
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
Reference in New Issue
Block a user