Skip to content

Commit 779950f

Browse files
committed
codestyle fixes
1 parent e820764 commit 779950f

File tree

6 files changed

+33
-29
lines changed

6 files changed

+33
-29
lines changed

examples/query-service/basic_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ def main():
2626
print(f"rows: {str(result_set.rows)}")
2727

2828

29-
if __name__ == '__main__':
29+
if __name__ == "__main__":
3030
main()

tests/query/test_query_transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
34
class TestQueryTransaction:
45
def test_tx_begin(self, tx):
56
assert tx.tx_id is None

ydb/_grpc/grpcwrapper/ydb_query.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ServerStatus,
1919
)
2020

21+
2122
@dataclass
2223
class CreateSessionResponse(IFromProto):
2324
status: Optional[ServerStatus]
@@ -68,13 +69,13 @@ def from_public(tx_mode: public_types.BaseQueryTxMode) -> "TransactionSettings":
6869
return TransactionSettings(tx_mode=tx_mode)
6970

7071
def to_proto(self) -> ydb_query_pb2.TransactionSettings:
71-
if self.tx_mode.name == 'snapshot_read_only':
72+
if self.tx_mode.name == "snapshot_read_only":
7273
return ydb_query_pb2.TransactionSettings(snapshot_read_only=self.tx_mode.to_proto())
73-
if self.tx_mode.name == 'serializable_read_write':
74+
if self.tx_mode.name == "serializable_read_write":
7475
return ydb_query_pb2.TransactionSettings(serializable_read_write=self.tx_mode.to_proto())
75-
if self.tx_mode.name == 'online_read_only':
76+
if self.tx_mode.name == "online_read_only":
7677
return ydb_query_pb2.TransactionSettings(online_read_only=self.tx_mode.to_proto())
77-
if self.tx_mode.name == 'stale_read_only':
78+
if self.tx_mode.name == "stale_read_only":
7879
return ydb_query_pb2.TransactionSettings(stale_read_only=self.tx_mode.to_proto())
7980

8081

@@ -87,7 +88,7 @@ def to_proto(self) -> ydb_query_pb2.BeginTransactionRequest:
8788
return ydb_query_pb2.BeginTransactionRequest(
8889
session_id=self.session_id,
8990
tx_settings=self.tx_settings.to_proto(),
90-
)
91+
)
9192

9293

9394
@dataclass
@@ -146,14 +147,8 @@ class TransactionControl(IToProto):
146147

147148
def to_proto(self) -> ydb_query_pb2.TransactionControl:
148149
if self.tx_id:
149-
return ydb_query_pb2.TransactionControl(
150-
tx_id=self.tx_id,
151-
commit_tx=self.commit_tx,
152-
)
153-
return ydb_query_pb2.TransactionControl(
154-
begin_tx=self.begin_tx.to_proto(),
155-
commit_tx=self.commit_tx
156-
)
150+
return ydb_query_pb2.TransactionControl(tx_id=self.tx_id,commit_tx=self.commit_tx)
151+
return ydb_query_pb2.TransactionControl(begin_tx=self.begin_tx.to_proto(), commit_tx=self.commit_tx)
157152

158153

159154
@dataclass

ydb/query/base.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .._grpc.grpcwrapper import ydb_query
1212
from .._grpc.grpcwrapper.ydb_query_public_types import (
1313
BaseQueryTxMode,
14-
QuerySerializableReadWrite
14+
QuerySerializableReadWrite,
1515
)
1616
from .. import convert
1717
from .. import issues
@@ -78,7 +78,13 @@ def transaction(self, tx_mode: BaseQueryTxMode) -> "IQueryTxContext":
7878
class IQueryTxContext(abc.ABC):
7979

8080
@abc.abstractmethod
81-
def __init__(self, driver: SupportedDriverType, session_state: IQuerySessionState, session: IQuerySession, tx_mode: BaseQueryTxMode = None):
81+
def __init__(
82+
self,
83+
driver: SupportedDriverType,
84+
session_state: IQuerySessionState,
85+
session: IQuerySession,
86+
tx_mode: BaseQueryTxMode = None
87+
):
8288
pass
8389

8490
@abc.abstractmethod
@@ -125,7 +131,9 @@ def session(self) -> IQuerySession:
125131
pass
126132

127133

128-
def create_execute_query_request(query: str, session_id: str, tx_id: str = None, commit_tx: bool = False, tx_mode: BaseQueryTxMode = None):
134+
def create_execute_query_request(
135+
query: str, session_id: str, tx_id: str = None, commit_tx: bool = False, tx_mode: BaseQueryTxMode = None
136+
):
129137
if tx_id:
130138
req = ydb_query.ExecuteQueryRequest(
131139
session_id=session_id,
@@ -134,7 +142,7 @@ def create_execute_query_request(query: str, session_id: str, tx_id: str = None,
134142
),
135143
tx_control=ydb_query.TransactionControl(
136144
tx_id=tx_id,
137-
commit_tx=commit_tx
145+
commit_tx=commit_tx,
138146
),
139147
)
140148
else:
@@ -148,7 +156,7 @@ def create_execute_query_request(query: str, session_id: str, tx_id: str = None,
148156
begin_tx=ydb_query.TransactionSettings(
149157
tx_mode=tx_mode,
150158
),
151-
commit_tx=commit_tx
159+
commit_tx=commit_tx,
152160
),
153161
)
154162

ydb/query/session.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QuerySessionStateHelper(abc.ABC):
3232
}
3333

3434
_READY_TO_USE = [
35-
QuerySessionStateEnum.CREATED
35+
QuerySessionStateEnum.CREATED,
3636
]
3737

3838
@classmethod
@@ -154,7 +154,7 @@ def _execute_call(self, query: str, commit_tx: bool):
154154
request = base.create_execute_query_request(
155155
query=query,
156156
session_id=self._state.session_id,
157-
commit_tx=commit_tx
157+
commit_tx=commit_tx,
158158
)
159159

160160
return self._driver(
@@ -189,13 +189,13 @@ def _attach(self):
189189
).start()
190190

191191
def _chech_session_status_loop(self, status_stream):
192-
try:
193-
for status in status_stream:
194-
if status.status != issues.StatusCode.SUCCESS:
195-
self._state.reset()
196-
self._state._change_state(QuerySessionStateEnum.CLOSED)
197-
except Exception as e:
198-
pass
192+
try:
193+
for status in status_stream:
194+
if status.status != issues.StatusCode.SUCCESS:
195+
self._state.reset()
196+
self._state._change_state(QuerySessionStateEnum.CLOSED)
197+
except Exception as e:
198+
pass
199199

200200

201201
def delete(self) -> None:

ydb/query/transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _execute_call(self, query: str, commit_tx: bool):
275275
request = base.create_execute_query_request(
276276
query=query,
277277
session_id=self._session_state.session_id,
278-
commit_tx=commit_tx
278+
commit_tx=commit_tx,
279279
)
280280
return self._driver(
281281
request,

0 commit comments

Comments
 (0)