From e3a52f6536fe1d3b69dc47b6383bece60227f050 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Thu, 26 Feb 2026 23:59:46 +0100 Subject: [PATCH] refactor: remove legacy models/schema/auth.py re-export file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All 84 import sites now use the canonical path app.modules.tenancy.schemas.auth directly — no need for backwards-compatibility re-exports. Update audit validator to check module schemas locations instead of only the legacy models/schema/ path. Co-Authored-By: Claude Opus 4.6 --- models/schema/__init__.py | 2 -- models/schema/auth.py | 34 --------------------------- scripts/validate/validate_audit.py | 37 ++++++++++++++++++++++-------- 3 files changed, 27 insertions(+), 46 deletions(-) delete mode 100644 models/schema/auth.py diff --git a/models/schema/__init__.py b/models/schema/__init__.py index fd64e3e2..09865e2a 100644 --- a/models/schema/__init__.py +++ b/models/schema/__init__.py @@ -23,7 +23,6 @@ Import schemas from their canonical module locations instead of this package. # Infrastructure schemas that remain here from . import ( - auth, base, ) @@ -32,5 +31,4 @@ from .base import * # Base Pydantic models __all__ = [ "base", - "auth", ] diff --git a/models/schema/auth.py b/models/schema/auth.py deleted file mode 100644 index a171c8f6..00000000 --- a/models/schema/auth.py +++ /dev/null @@ -1,34 +0,0 @@ -# models/schema/auth.py -""" -LEGACY LOCATION — re-exports from canonical location. - -All auth schemas have been moved to app/modules/tenancy/schemas/auth.py -per MOD-019 (schemas belong in their module). - -This file provides backwards compatibility re-exports. -New code should import from: app.modules.tenancy.schemas.auth - -Schemas use Pydantic Field and field_validator for input validation. -""" - -from app.modules.tenancy.schemas.auth import ( # noqa: F401 - LoginResponse, - LogoutResponse, - OwnedMerchantSummary, - PasswordResetRequestResponse, - PasswordResetResponse, - PlatformSelectResponse, - StoreMembershipSummary, - StoreUserResponse, - UserContext, - UserCreate, - UserDeleteResponse, - UserDetailResponse, - UserListResponse, - UserLogin, - UserResponse, - UserSearchItem, - UserSearchResponse, - UserStatusToggleResponse, - UserUpdate, -) diff --git a/scripts/validate/validate_audit.py b/scripts/validate/validate_audit.py index c18ac030..b448b567 100644 --- a/scripts/validate/validate_audit.py +++ b/scripts/validate/validate_audit.py @@ -205,20 +205,37 @@ class AuditValidator(BaseValidator): ) # Check input validation (Pydantic) - schema_path = self.project_root / "models" / "schema" - if schema_path.exists(): - has_validation = False - for file in schema_path.glob("*.py"): + # Check both legacy models/schema/ and module schemas locations + schema_paths = [ + self.project_root / "models" / "schema", + self.project_root / "app" / "modules", + ] + has_validation = False + for schema_path in schema_paths: + if not schema_path.exists(): + continue + for file in schema_path.rglob("schemas/*.py"): content = file.read_text() if re.search(r"Field|validator|field_validator", content): has_validation = True break - if not has_validation: - self.add_error( - "DATA-INT-001", - "Pydantic validation required for data integrity", - str(schema_path), - ) + if has_validation: + break + # Also check legacy location + if schema_path == self.project_root / "models" / "schema": + for file in schema_path.glob("*.py"): + content = file.read_text() + if re.search(r"Field|validator|field_validator", content): + has_validation = True + break + if has_validation: + break + if not has_validation: + self.add_error( + "DATA-INT-001", + "Pydantic validation required for data integrity", + str(self.project_root / "app" / "modules"), + ) # Check user data access endpoint exists (GDPR) users_api = self.project_root / "app" / "api" / "v1" / "users.py"