Skip to content

Commit 3359915

Browse files
committed
Switch from flake8 to ruff
1 parent a85823f commit 3359915

File tree

6 files changed

+11
-23
lines changed

6 files changed

+11
-23
lines changed

syncmaster/db/models/transfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Transfer(
6060

6161
source_connection: Mapped[Connection] = relationship(foreign_keys=source_connection_id)
6262
target_connection: Mapped[Connection] = relationship(foreign_keys=target_connection_id)
63-
queue: Mapped[Queue] = relationship(back_populates="transfers")
63+
queue: Mapped[Queue] = relationship()
6464

6565
search_vector: Mapped[str] = mapped_column(
6666
TSVECTOR,

syncmaster/db/repositories/queue.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from sqlalchemy import ScalarResult, insert, select
66
from sqlalchemy.exc import DBAPIError, IntegrityError, NoResultFound
77
from sqlalchemy.ext.asyncio import AsyncSession
8-
from sqlalchemy.orm import selectinload
98

109
from syncmaster.db.models import Group, GroupMemberRole, Queue, User, UserGroup
1110
from syncmaster.db.repositories.repository_with_owner import RepositoryWithOwner
@@ -15,9 +14,6 @@
1514
from syncmaster.exceptions.group import GroupNotFoundError
1615
from syncmaster.exceptions.queue import DuplicatedQueueNameError, QueueNotFoundError
1716

18-
# TODO: remove HTTP response schemes from repositories, these are different layers
19-
from syncmaster.schemas.v1.queue import UpdateQueueSchema
20-
2117

2218
class QueueRepository(RepositoryWithOwner[Queue]):
2319
def __init__(self, session: AsyncSession):
@@ -37,12 +33,7 @@ async def read_by_id(
3733
self,
3834
queue_id: int,
3935
) -> Queue:
40-
stmt = (
41-
select(Queue)
42-
.where(Queue.id == queue_id)
43-
.options(selectinload(Queue.transfers))
44-
.options(selectinload(Queue.group))
45-
)
36+
stmt = select(Queue).where(Queue.id == queue_id)
4637
try:
4738
result: ScalarResult[Queue] = await self._session.scalars(stmt)
4839
return result.one()
@@ -69,16 +60,12 @@ async def paginate(
6960
page_size=page_size,
7061
)
7162

72-
async def update(
73-
self,
74-
queue_id: int,
75-
queue_data: UpdateQueueSchema,
76-
) -> Queue:
63+
async def update(self, queue_id: int, name: str, description: str) -> Queue:
7764
try:
7865
return await self._update(
7966
Queue.id == queue_id,
80-
name=queue_data.name,
81-
description=queue_data.description,
67+
name=name,
68+
description=description,
8269
)
8370
except IntegrityError as e:
8471
self._raise_error(e)

syncmaster/server/api/v1/queue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ async def update_queue(
118118
async with unit_of_work:
119119
queue = await unit_of_work.queue.update(
120120
queue_id=queue_id,
121-
queue_data=queue_data,
121+
name=queue_data.name,
122+
description=queue_data.description,
122123
)
123124
return ReadQueueSchema.model_validate(queue, from_attributes=True)
124125

tests/test_unit/test_connections/test_update_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ async def test_developer_plus_update_oracle_connection_both_sid_and_service_name
480480
role_developer_plus: UserTestRoles,
481481
):
482482
user = group_connection.owner_group.get_member_of_role(role_developer_plus)
483-
group_id = group_connection.connection.group.id
483+
group_id = group_connection.connection.group_id
484484

485485
response = await client.put(
486486
f"v1/connections/{group_connection.id}",

tests/test_unit/test_queues/test_create_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async def test_maintainer_plus_can_not_create_queue_with_duplicate_name_error(
309309
json={
310310
"name": group_queue.name, # duplicated name
311311
"description": "Some interesting description",
312-
"group_id": group_queue.group.id,
312+
"group_id": group_queue.group_id,
313313
},
314314
)
315315

tests/test_unit/test_queues/test_read_queue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def test_group_member_can_read_queue(
2626
"name": group_queue.name,
2727
"description": group_queue.description,
2828
"group_id": group_queue.group_id,
29-
"slug": f"{group_queue.group.id}-{group_queue.name}",
29+
"slug": f"{group_queue.group_id}-{group_queue.name}",
3030
}
3131

3232

@@ -46,7 +46,7 @@ async def test_superuser_can_read_queue(
4646
"name": group_queue.name,
4747
"description": group_queue.description,
4848
"group_id": group_queue.group_id,
49-
"slug": f"{group_queue.group.id}-{group_queue.name}",
49+
"slug": f"{group_queue.group_id}-{group_queue.name}",
5050
}
5151

5252

0 commit comments

Comments
 (0)