diff --git a/backend/app/api/controllers/search_controller.py b/backend/app/api/controllers/search_controller.py index 8f5f3b50dd..2ecfd85c95 100644 --- a/backend/app/api/controllers/search_controller.py +++ b/backend/app/api/controllers/search_controller.py @@ -18,7 +18,7 @@ def __init__(self) -> None: def _serialize_datetime(self, obj: Any) -> Any: """Recursively serialize datetime objects to ISO format strings""" - if isinstance(obj, (str, int, float, bool, type(None))): + if isinstance(obj, str | int | float | bool) or obj is None: return obj elif hasattr(obj, "isoformat"): # datetime objects return obj.isoformat() diff --git a/backend/app/services/dropbox_service.py b/backend/app/services/dropbox_service.py index 33eda176b2..569bbf874c 100644 --- a/backend/app/services/dropbox_service.py +++ b/backend/app/services/dropbox_service.py @@ -742,6 +742,10 @@ def process_matches(matches): dbx_ns.files_search_v2, search_arg ) + # Capture loop variables to avoid B023 error + namespace_id = ns.namespace_id + namespace_name = ns.name + def process_ns_matches(matches): for match in matches: if hasattr(match, "metadata") and hasattr( @@ -757,8 +761,8 @@ def process_ns_matches(matches): "path_display": entry.path_display, ".tag": "file" if is_file else "folder", "namespace_type": "team", - "namespace_id": ns.namespace_id, - "namespace_name": ns.name, + "namespace_id": namespace_id, + "namespace_name": namespace_name, } if is_file: diff --git a/backend/tests/api/routes/test_dropbox.py b/backend/tests/api/routes/test_dropbox.py index 5e4a593b7e..9ce9464482 100644 --- a/backend/tests/api/routes/test_dropbox.py +++ b/backend/tests/api/routes/test_dropbox.py @@ -19,7 +19,7 @@ def test_user(db: Session) -> User: """Create a test user.""" user = User( - email="dropbox_test@example.com", + email=f"dropbox_test_{uuid.uuid4()}@example.com", hashed_password="hashed", first_name="Test", last_name="User", diff --git a/backend/tests/api/routes/test_one_drive.py b/backend/tests/api/routes/test_one_drive.py index 02624807f7..bf3766d890 100644 --- a/backend/tests/api/routes/test_one_drive.py +++ b/backend/tests/api/routes/test_one_drive.py @@ -19,7 +19,7 @@ def test_user(db: Session) -> User: """Create a test user.""" user = User( - email="onedrive_test@example.com", + email=f"onedrive_test_{uuid.uuid4()}@example.com", hashed_password="hashed", first_name="Test", last_name="User", diff --git a/backend/tests/unit/test_external_account.py b/backend/tests/unit/test_external_account.py index 6ac9eea1cd..31fafce5cd 100644 --- a/backend/tests/unit/test_external_account.py +++ b/backend/tests/unit/test_external_account.py @@ -14,7 +14,7 @@ def test_external_account_model_creation(db: Session): """Test ExternalAccount model creation to ensure TYPE_CHECKING import is exercised.""" # Create a user first user = User( - email="test@example.com", + email=f"test_external_account_{uuid.uuid4()}@example.com", hashed_password="hashed", first_name="Test", last_name="User", diff --git a/backend/tests/unit/test_one_drive_service.py b/backend/tests/unit/test_one_drive_service.py index 2a7a015ab5..b0c32f30cd 100644 --- a/backend/tests/unit/test_one_drive_service.py +++ b/backend/tests/unit/test_one_drive_service.py @@ -24,7 +24,7 @@ def service(): def test_user(db: Session) -> User: """Create a test user.""" user = User( - email="test@example.com", + email=f"test_onedrive_service_{uuid.uuid4()}@example.com", hashed_password="hashed", first_name="Test", last_name="User",