Skip to content

Commit d58ab20

Browse files
style: fix ruff linting errors (imports, comparisons)
1 parent 607cb02 commit d58ab20

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

alembic/env.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Alembic environment configuration for async SQLAlchemy."""
22
import asyncio
33
from logging.config import fileConfig
4+
from typing import Any
45

56
from sqlalchemy import pool
67
from sqlalchemy.ext.asyncio import async_engine_from_config
@@ -39,9 +40,6 @@ def run_migrations_offline() -> None:
3940
context.run_migrations()
4041

4142

42-
from typing import Any
43-
44-
4543
def do_run_migrations(connection: Any) -> None:
4644
"""Run migrations with connection."""
4745
context.configure(connection=connection, target_metadata=target_metadata)

tests/integration/test_init_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def test_create_initial_admin(test_session: AsyncSession) -> None:
2828
result = await test_session.execute(select(User).where(User.email == "admin@example.com"))
2929
admin = result.scalars().first()
3030
assert admin is not None
31-
assert admin.is_superuser == True
31+
assert admin.is_superuser == True # noqa: E712
3232
assert admin.email == "admin@example.com"
3333

3434
# Run again (idempotency)

tests/unit/test_content_service_extended.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import pytest
2-
from unittest.mock import AsyncMock, patch, MagicMock
1+
from unittest.mock import AsyncMock, MagicMock, patch
32
from uuid import uuid4
3+
4+
import pytest
45
from fastapi import HTTPException
56

67
from app.models.client import Client
8+
from app.models.guide import ComplexityLevel, Guide
79
from app.models.topic import Topic
8-
from app.models.guide import Guide, ComplexityLevel
9-
from app.schemas.topic import TopicCreate
1010
from app.schemas.guide import GuideCreate
1111
from app.services.content import content_service
1212

@@ -46,15 +46,17 @@ async def test_create_guide_success() -> None:
4646
)
4747

4848
# We need to mock get_topic to succeed (it checks access)
49-
with patch.object(content_service, "get_topic", return_value=topic) as mock_get_topic:
50-
with patch("app.services.content.guide_repo.get_by_slug", return_value=None):
51-
mock_session.add = MagicMock()
49+
with (
50+
patch.object(content_service, "get_topic", return_value=topic) as mock_get_topic,
51+
patch("app.services.content.guide_repo.get_by_slug", return_value=None),
52+
):
53+
mock_session.add = MagicMock()
5254

53-
result = await content_service.create_guide(mock_session, client, guide_in)
55+
result = await content_service.create_guide(mock_session, client, guide_in)
5456

55-
assert result.title == "Guide 1"
56-
assert result.client_id == client.id
57-
mock_get_topic.assert_awaited_once_with(mock_session, client, topic.id)
57+
assert result.title == "Guide 1"
58+
assert result.client_id == client.id
59+
mock_get_topic.assert_awaited_once_with(mock_session, client, topic.id)
5860

5961

6062
@pytest.mark.asyncio()
@@ -73,12 +75,13 @@ async def test_create_guide_slug_collision() -> None:
7375
complexity_level=ComplexityLevel.BEGINNER,
7476
)
7577

76-
with patch.object(content_service, "get_topic", return_value=topic):
77-
# Return an existing object to trigger collision
78-
with patch("app.services.content.guide_repo.get_by_slug", return_value=Guide()):
79-
with pytest.raises(HTTPException) as exc:
80-
await content_service.create_guide(mock_session, client, guide_in)
81-
assert exc.value.status_code == 400
78+
with (
79+
patch.object(content_service, "get_topic", return_value=topic),
80+
patch("app.services.content.guide_repo.get_by_slug", return_value=Guide()),
81+
):
82+
with pytest.raises(HTTPException) as exc:
83+
await content_service.create_guide(mock_session, client, guide_in)
84+
assert exc.value.status_code == 400
8285

8386

8487
@pytest.mark.asyncio()

tests/unit/test_crud_base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Unit tests for CRUDBase generic repository."""
2-
from uuid import uuid4, UUID
2+
from uuid import uuid4
33

44
import pytest
55
from pydantic import BaseModel, EmailStr
@@ -48,8 +48,8 @@ async def test_create_user(self, test_session: AsyncSession) -> None:
4848
# Assert
4949
assert created_user.id is not None
5050
assert created_user.email == "newuser@example.com"
51-
assert created_user.is_active == True
52-
assert created_user.is_superuser == False
51+
assert created_user.is_active == True # noqa: E712
52+
assert created_user.is_superuser == False # noqa: E712
5353

5454
async def test_get_user(self, test_session: AsyncSession, test_user: User) -> None:
5555
"""Test retrieving a user by ID."""
@@ -119,7 +119,7 @@ async def test_update_user(self, test_session: AsyncSession, test_user: User) ->
119119
# Assert
120120
assert updated_user.id == test_user.id
121121
assert updated_user.email == "updated@example.com"
122-
assert updated_user.is_active == False
122+
assert updated_user.is_active == False # noqa: E712
123123

124124
async def test_update_user_with_dict(self, test_session: AsyncSession, test_user: User) -> None:
125125
"""Test updating a user with a dictionary."""
@@ -130,7 +130,7 @@ async def test_update_user_with_dict(self, test_session: AsyncSession, test_user
130130
updated_user = await user_crud.update(test_session, db_obj=test_user, obj_in=update_data)
131131

132132
# Assert
133-
assert updated_user.is_superuser == True
133+
assert updated_user.is_superuser == True # noqa: E712
134134
assert updated_user.email == test_user.email # Unchanged
135135

136136
async def test_partial_update(self, test_session: AsyncSession, test_user: User) -> None:
@@ -144,7 +144,7 @@ async def test_partial_update(self, test_session: AsyncSession, test_user: User)
144144

145145
# Assert
146146
assert updated_user.email == original_email # Unchanged
147-
assert updated_user.is_active == False # Changed
147+
assert updated_user.is_active == False # noqa: E712
148148

149149
async def test_delete_user(self, test_session: AsyncSession, test_user: User) -> None:
150150
"""Test deleting a user."""

0 commit comments

Comments
 (0)