Skip to content

Commit 2175a80

Browse files
committed
style: format by ruff
1 parent 45d0a86 commit 2175a80

File tree

24 files changed

+176
-221
lines changed

24 files changed

+176
-221
lines changed

src/tgdb/application/horizon/commit_transaction.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class CommitTransaction:
3535
channel: Channel
3636
commit_buffer: Buffer[Commit | PreparedCommit]
3737

38-
async def __call__(
39-
self, xid: XID, operators: Sequence[Operator]
40-
) -> None:
38+
async def __call__(self, xid: XID, operators: Sequence[Operator]) -> None:
4139
"""
4240
:raises tgdb.application.relation.ports.relations.NoRelationError:
4341
:raises tgdb.entities.horizon.horizon.NoTransactionError:

src/tgdb/application/horizon/output_commits.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ async def __call__(self) -> None:
3737
try:
3838
horizon.complete_commit(time, commit.xid)
3939
except (
40-
NoTransactionError, TransactionNotCommittingError
40+
NoTransactionError,
41+
TransactionNotCommittingError,
4142
) as error:
4243
await self.channel.publish(commit.xid, error)
4344
else:

src/tgdb/entities/horizon/horizon.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ def commit_transaction(
158158
self.move_to_future(time)
159159

160160
transaction = self._transaction(
161-
xid, SerializableTransactionState.active,
161+
xid,
162+
SerializableTransactionState.active,
162163
else_=TransactionCommittingError(),
163164
)
164165

@@ -243,7 +244,7 @@ def _is_transaction_autorollbackable(
243244
) -> bool:
244245
return (
245246
not isinstance(transaction, SerializableTransaction)
246-
or transaction.state is not SerializableTransactionState.prepared
247+
or transaction.state() is not SerializableTransactionState.prepared
247248
)
248249

249250
def _oldest_transaction(self) -> Transaction | None:

src/tgdb/entities/horizon/transaction.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,13 @@ def include(self, effect: ConflictableTransactionScalarEffect) -> None:
251251

252252
self._space[effect.tid] = effect
253253

254-
def rollback(self) -> None:
255-
...
254+
def rollback(self) -> None: ...
256255

257256
def commit(self) -> Commit:
258257
return Commit(self._xid, frozenset(self._space.values()))
259258

260259
@classmethod
261-
def start(
262-
cls, xid: XID, time: LogicTime
263-
) -> "ReadUncommitedTransaction":
260+
def start(cls, xid: XID, time: LogicTime) -> "ReadUncommitedTransaction":
264261
return ReadUncommitedTransaction(
265262
_xid=xid,
266263
_start_time=time,

src/tgdb/entities/relation/domain.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,5 @@ class UuidDomain(_TypeDomain):
6161

6262

6363
type Domain = (
64-
IntDomain
65-
| StrDomain
66-
| BoolDomain
67-
| DatetimeDomain
68-
| UuidDomain
69-
| SetDomain
64+
IntDomain | StrDomain | BoolDomain | DatetimeDomain | UuidDomain | SetDomain
7065
)

src/tgdb/entities/relation/tuple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def __getitem__(self, index: int, /) -> Scalar: ...
3939
@overload
4040
def __getitem__(
4141
self, sclice: "slice[Any, Any, Any]", /
42-
) -> Sequence[Scalar]:
43-
...
42+
) -> Sequence[Scalar]: ...
4443

4544
def __getitem__(
4645
self, key: "int | slice[Any, Any, Any]", /

src/tgdb/entities/relation/tuple_effect.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def tid(self) -> TID:
3737
class MutatedTuple:
3838
tuple: Tuple
3939

40-
def __and__(self, effect: "TupleEffect") -> "MutatedTuple | DeletedTuple | MigratedTuple":
40+
def __and__(
41+
self, effect: "TupleEffect"
42+
) -> "MutatedTuple | DeletedTuple | MigratedTuple":
4143
match effect:
4244
case JustViewedTuple():
4345
return self
@@ -55,7 +57,9 @@ def tid(self) -> TID:
5557
class MigratedTuple:
5658
tuple: Tuple
5759

58-
def __and__(self, effect: "TupleEffect") -> "MutatedTuple | MigratedTuple | DeletedTuple":
60+
def __and__(
61+
self, effect: "TupleEffect"
62+
) -> "MutatedTuple | MigratedTuple | DeletedTuple":
5963
match effect:
6064
case JustViewedTuple():
6165
return self
@@ -94,11 +98,7 @@ class InvalidRelationTupleError(Exception):
9498

9599

96100
type TupleEffect = (
97-
NewTuple
98-
| JustViewedTuple
99-
| MutatedTuple
100-
| MigratedTuple
101-
| DeletedTuple
101+
NewTuple | JustViewedTuple | MutatedTuple | MigratedTuple | DeletedTuple
102102
)
103103

104104

src/tgdb/infrastructure/adapters/buffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def add(self, commit: Commit | PreparedCommit, /) -> None:
8181
await self._buffer.add(commit)
8282

8383
async def __aiter__(
84-
self
84+
self,
8585
) -> AsyncIterator[Sequence[Commit | PreparedCommit]]:
8686
async for commits in self._buffer:
8787
encoded_commits = pickle.dumps(list(commits))

src/tgdb/infrastructure/adapters/tuples.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@
3232
class InMemoryTuples(Tuples):
3333
_db: InMemoryDb[Tuple]
3434

35-
async def assert_can_accept_tuples(self, relation: Relation) -> None:
36-
...
35+
async def assert_can_accept_tuples(self, relation: Relation) -> None: ...
3736

3837
async def tuples_with_attribute(
3938
self,
4039
relation_number: Number,
4140
attribute_number: Number,
4241
attribute_scalar: Scalar,
4342
) -> Sequence[Tuple]:
44-
return self._db.select_many(lambda it: (
45-
it.relation_schema_id.relation_number == relation_number
46-
and len(it) >= int(attribute_number)
47-
and it[int(attribute_number)] == attribute_scalar
48-
))
43+
return self._db.select_many(
44+
lambda it: (
45+
it.relation_schema_id.relation_number == relation_number
46+
and len(it) >= int(attribute_number)
47+
and it[int(attribute_number)] == attribute_scalar
48+
)
49+
)
4950

5051
async def map(self, effects: Sequence[TransactionEffect]) -> None:
5152
await gather(*map(self._map_one, effects))
@@ -75,7 +76,8 @@ async def _map_one(self, effect: TransactionEffect) -> None:
7576
self._db.remove(prevous_tuple)
7677
self._db.insert(next_tuple)
7778

78-
case _: ...
79+
case _:
80+
...
7981

8082
async def _map_one_idempotently(self, effect: TransactionEffect) -> None:
8183
for tuple_effect in effect:
@@ -91,7 +93,8 @@ async def _map_one_idempotently(self, effect: TransactionEffect) -> None:
9193
self._db.remove(prevous_tuple)
9294
self._db.insert(next_tuple)
9395

94-
case _: ...
96+
case _:
97+
...
9598

9699

97100
@dataclass(frozen=True)
@@ -120,20 +123,24 @@ async def tuples_with_attribute(
120123
async def map(
121124
self, transaction_effects: Sequence[TransactionEffect]
122125
) -> None:
123-
await gather(*(
124-
self._map_scalar_effect(tuple_effect, idempotently=False)
125-
for transaction_effect in transaction_effects
126-
for tuple_effect in transaction_effect
127-
))
126+
await gather(
127+
*(
128+
self._map_scalar_effect(tuple_effect, idempotently=False)
129+
for transaction_effect in transaction_effects
130+
for tuple_effect in transaction_effect
131+
)
132+
)
128133

129134
async def map_idempotently(
130135
self, transaction_effects: Sequence[TransactionEffect]
131136
) -> None:
132-
await gather(*(
133-
self._map_scalar_effect(tuple_effect, idempotently=True)
134-
for transaction_effect in transaction_effects
135-
for tuple_effect in transaction_effect
136-
))
137+
await gather(
138+
*(
139+
self._map_scalar_effect(tuple_effect, idempotently=True)
140+
for transaction_effect in transaction_effects
141+
for tuple_effect in transaction_effect
142+
)
143+
)
137144

138145
async def _map_scalar_effect(
139146
self, scalar_effect: TransactionScalarEffect, idempotently: bool

src/tgdb/infrastructure/async_map.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
@dataclass(frozen=True, unsafe_hash=False)
77
class AsyncMap[KeyT, ValueT]:
8-
_map: dict[KeyT, Future[ValueT]] = field(
9-
init=False, default_factory=dict
10-
)
8+
_map: dict[KeyT, Future[ValueT]] = field(init=False, default_factory=dict)
119

1210
def __iter__(self) -> Iterator[KeyT]:
1311
return iter(self._map)

0 commit comments

Comments
 (0)