Skip to content

Commit 7d78387

Browse files
committed
add style checking
1 parent 53d547b commit 7d78387

File tree

3 files changed

+37
-44
lines changed

3 files changed

+37
-44
lines changed

tests/coordination/test_coordination_client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ async def test_coordination_lock_full_lifecycle(self, aio_connection):
147147
assert list(sem2.owners) == []
148148
assert list(sem2.waiters) == []
149149

150-
151150
lock2_started = asyncio.Event()
152151
lock2_acquired = asyncio.Event()
153152

@@ -191,10 +190,8 @@ async def second_lock_task():
191190
sem3 = resp3.semaphore_description
192191
assert sem3.count == 1
193192

194-
195193
delete_resp = await lock.delete()
196194
assert delete_resp.status == StatusCode.SUCCESS
197195

198196
describe_after_delete = await lock.describe()
199197
assert describe_after_delete.status == StatusCode.NOT_FOUND
200-

ydb/_grpc/grpcwrapper/ydb_coordination.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ class SessionStart(IToProto):
6767
protection_key: bytes = b""
6868

6969
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
70-
return ydb_coordination_pb2.SessionRequest(session_start=ydb_coordination_pb2.SessionRequest.SessionStart(
71-
path=self.path,
72-
session_id=self.session_id,
73-
timeout_millis=self.timeout_millis,
74-
description=self.description,
75-
seq_no=self.seq_no,
76-
protection_key=self.protection_key,
77-
))
70+
return ydb_coordination_pb2.SessionRequest(
71+
session_start=ydb_coordination_pb2.SessionRequest.SessionStart(
72+
path=self.path,
73+
session_id=self.session_id,
74+
timeout_millis=self.timeout_millis,
75+
description=self.description,
76+
seq_no=self.seq_no,
77+
protection_key=self.protection_key,
78+
)
79+
)
7880

7981

8082
@dataclass
@@ -89,7 +91,8 @@ class Ping(IToProto):
8991

9092
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
9193
return ydb_coordination_pb2.SessionRequest(
92-
ping=ydb_coordination_pb2.SessionRequest.PingPong(opaque=self.opaque))
94+
ping=ydb_coordination_pb2.SessionRequest.PingPong(opaque=self.opaque)
95+
)
9396

9497

9598
@dataclass
@@ -100,9 +103,11 @@ class CreateSemaphore(IToProto):
100103
data: bytes = b""
101104

102105
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
103-
return ydb_coordination_pb2.SessionRequest(create_semaphore=ydb_coordination_pb2.SessionRequest.CreateSemaphore(
104-
req_id=self.req_id, name=self.name, limit=self.limit, data=self.data
105-
))
106+
return ydb_coordination_pb2.SessionRequest(
107+
create_semaphore=ydb_coordination_pb2.SessionRequest.CreateSemaphore(
108+
req_id=self.req_id, name=self.name, limit=self.limit, data=self.data
109+
)
110+
)
106111

107112

108113
@dataclass
@@ -112,9 +117,11 @@ class UpdateSemaphore(IToProto):
112117
data: bytes
113118

114119
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
115-
return ydb_coordination_pb2.SessionRequest(update_semaphore=ydb_coordination_pb2.SessionRequest.UpdateSemaphore(
116-
req_id=self.req_id, name=self.name, data=self.data
117-
))
120+
return ydb_coordination_pb2.SessionRequest(
121+
update_semaphore=ydb_coordination_pb2.SessionRequest.UpdateSemaphore(
122+
req_id=self.req_id, name=self.name, data=self.data
123+
)
124+
)
118125

119126

120127
@dataclass
@@ -124,9 +131,11 @@ class DeleteSemaphore(IToProto):
124131
force: bool = False
125132

126133
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
127-
return ydb_coordination_pb2.SessionRequest(delete_semaphore=ydb_coordination_pb2.SessionRequest.DeleteSemaphore(
128-
req_id=self.req_id, name=self.name, force=self.force
129-
))
134+
return ydb_coordination_pb2.SessionRequest(
135+
delete_semaphore=ydb_coordination_pb2.SessionRequest.DeleteSemaphore(
136+
req_id=self.req_id, name=self.name, force=self.force
137+
)
138+
)
130139

131140

132141
@dataclass
@@ -147,7 +156,8 @@ def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
147156
count=self.count,
148157
data=self.data,
149158
ephemeral=self.ephemeral,
150-
))
159+
)
160+
)
151161

152162

153163
@dataclass
@@ -157,9 +167,9 @@ class ReleaseSemaphore(IToProto):
157167

158168
def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
159169
return ydb_coordination_pb2.SessionRequest(
160-
release_semaphore=ydb_coordination_pb2.SessionRequest.ReleaseSemaphore(
161-
req_id=self.req_id, name=self.name
162-
))
170+
release_semaphore=ydb_coordination_pb2.SessionRequest.ReleaseSemaphore(req_id=self.req_id, name=self.name)
171+
)
172+
163173

164174
@dataclass
165175
class DescribeSemaphore(IToProto):
@@ -178,7 +188,7 @@ def to_proto(self) -> ydb_coordination_pb2.SessionRequest:
178188
name=self.name,
179189
req_id=self.req_id,
180190
watch_data=self.watch_data,
181-
watch_owners=self.watch_owners
191+
watch_owners=self.watch_owners,
182192
)
183193
)
184194

ydb/aio/coordination/lock.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def __init__(
4646

4747
self._wait_timeout: float = self._timeout_millis / 1000.0
4848

49-
5049
def next_req_id(self) -> int:
5150
r = self._next_req_id
5251
self._next_req_id += 1
@@ -100,13 +99,10 @@ async def _wait_for_response(self, req_id: int, *, kind: str):
10099
"describe": "describe",
101100
"update": "update",
102101
"delete": "delete",
103-
"create": "create"
102+
"create": "create",
104103
}.get(kind, "operation")
105104

106-
raise issues.Error(
107-
f"Timeout waiting for lock {self._name} {action}"
108-
)
109-
105+
raise issues.Error(f"Timeout waiting for lock {self._name} {action}")
110106

111107
async def __aenter__(self):
112108
await self._ensure_session()
@@ -157,12 +153,7 @@ async def create(self, init_limit, init_data):
157153

158154
req_id = self.next_req_id()
159155

160-
req = CreateSemaphore(
161-
req_id=req_id,
162-
name=self._name,
163-
limit=init_limit,
164-
data=init_data
165-
).to_proto()
156+
req = CreateSemaphore(req_id=req_id, name=self._name, limit=init_limit, data=init_data).to_proto()
166157

167158
await self.send(req)
168159

@@ -184,7 +175,6 @@ async def delete(self):
184175
resp = await self._wait_for_response(req_id, kind="delete")
185176
return resp
186177

187-
188178
async def describe(self):
189179
await self._ensure_session()
190180

@@ -208,11 +198,7 @@ async def update(self, new_data):
208198
await self._ensure_session()
209199

210200
req_id = self.next_req_id()
211-
req = UpdateSemaphore(
212-
req_id=req_id,
213-
name=self._name,
214-
data=new_data
215-
).to_proto()
201+
req = UpdateSemaphore(req_id=req_id, name=self._name, data=new_data).to_proto()
216202

217203
await self.send(req)
218204

0 commit comments

Comments
 (0)