Skip to content

Commit b37b1ba

Browse files
committed
fix: linting:all
1 parent 5f7a836 commit b37b1ba

File tree

5 files changed

+47
-25
lines changed

5 files changed

+47
-25
lines changed

src/aleph/db/accessors/messages.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,7 @@ def get_distinct_channels(session: DbSession) -> Iterable[Channel]:
376376
return session.execute(select_stmt).scalars()
377377

378378

379-
def get_distinct_post_types_for_address(
380-
session: DbSession, address: str
381-
) -> list[str]:
379+
def get_distinct_post_types_for_address(session: DbSession, address: str) -> list[str]:
382380
"""Get distinct post_types for POST messages published by an address."""
383381
select_stmt = (
384382
select(MessageDb.content["type"].astext)
@@ -390,9 +388,7 @@ def get_distinct_post_types_for_address(
390388
return list(session.execute(select_stmt).scalars())
391389

392390

393-
def get_distinct_channels_for_address(
394-
session: DbSession, address: str
395-
) -> list[str]:
391+
def get_distinct_channels_for_address(session: DbSession, address: str) -> list[str]:
396392
"""Get distinct channels for messages published by an address (all message types, excluding null channels)."""
397393
select_stmt = (
398394
select(MessageDb.channel)

src/aleph/db/accessors/posts.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
)
1414

1515
from aleph_message.models import Chain, ItemHash, ItemType
16-
from sqlalchemy import TIMESTAMP, Float, String, case
16+
from sqlalchemy import (
17+
TIMESTAMP,
18+
Float,
19+
String,
20+
case,
21+
)
1722
from sqlalchemy import cast as sqla_cast
1823
from sqlalchemy import (
1924
delete,

src/aleph/handlers/content/post.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from aleph_message.models import Chain, ChainRef, PostContent
66
from sqlalchemy import update
77

8-
from aleph.db.accessors.balances import get_credit_balance
8+
from aleph.db.accessors.balances import (
9+
get_credit_balance,
10+
)
911
from aleph.db.accessors.balances import update_balances as update_balances_db
1012
from aleph.db.accessors.balances import (
1113
update_credit_balances_distribution as update_credit_balances_distribution_db,
@@ -16,7 +18,9 @@
1618
from aleph.db.accessors.balances import (
1719
update_credit_balances_transfer as update_credit_balances_transfer_db,
1820
)
19-
from aleph.db.accessors.balances import validate_credit_transfer_balance
21+
from aleph.db.accessors.balances import (
22+
validate_credit_transfer_balance,
23+
)
2024
from aleph.db.accessors.posts import (
2125
delete_amends,
2226
delete_post,

src/aleph/web/controllers/accounts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
AddressCreditBalanceResponse,
3131
CreditHistoryResponseItem,
3232
GetAccountBalanceResponse,
33+
GetAccountChannelsResponse,
3334
GetAccountCreditHistoryQueryParams,
3435
GetAccountCreditHistoryResponse,
3536
GetAccountFilesQueryParams,
3637
GetAccountFilesResponse,
37-
GetAccountChannelsResponse,
3838
GetAccountFilesResponseItem,
3939
GetAccountPostTypesResponse,
4040
GetAccountQueryParams,
@@ -326,9 +326,7 @@ async def get_account_channels(request: web.Request) -> web.Response:
326326
session_factory: DbSessionFactory = get_session_factory_from_request(request)
327327

328328
with session_factory() as session:
329-
channels = get_distinct_channels_for_address(
330-
session=session, address=address
331-
)
329+
channels = get_distinct_channels_for_address(session=session, address=address)
332330

333331
response = GetAccountChannelsResponse(
334332
address=address,

tests/api/test_accounts.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from aleph.db.models import MessageDb
88
from aleph.db.models.messages import MessageStatusDb
9-
from aleph.toolkit.timestamp import timestamp_to_datetime, utc_now
9+
from aleph.toolkit.timestamp import utc_now
1010
from aleph.types.channel import Channel
1111
from aleph.types.db_session import DbSessionFactory
1212
from aleph.types.message_status import MessageStatus
@@ -30,7 +30,9 @@ def fixture_post_messages_with_types(
3030
signature="0x" + "0" * 128,
3131
item_type=ItemType.inline,
3232
type=MessageType.post,
33-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126646.5,"type":"blog","content":{"title":"Post 1"}}',
33+
item_content='{"address":"'
34+
+ TEST_ADDRESS
35+
+ '","time":1652126646.5,"type":"blog","content":{"title":"Post 1"}}',
3436
content={
3537
"address": TEST_ADDRESS,
3638
"time": 1652126646.5,
@@ -48,7 +50,9 @@ def fixture_post_messages_with_types(
4850
signature="0x" + "0" * 128,
4951
item_type=ItemType.inline,
5052
type=MessageType.post,
51-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126647.5,"type":"blog","content":{"title":"Post 2"}}',
53+
item_content='{"address":"'
54+
+ TEST_ADDRESS
55+
+ '","time":1652126647.5,"type":"blog","content":{"title":"Post 2"}}',
5256
content={
5357
"address": TEST_ADDRESS,
5458
"time": 1652126647.5,
@@ -66,7 +70,9 @@ def fixture_post_messages_with_types(
6670
signature="0x" + "0" * 128,
6771
item_type=ItemType.inline,
6872
type=MessageType.post,
69-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126648.5,"type":"news","content":{"title":"News 1"}}',
73+
item_content='{"address":"'
74+
+ TEST_ADDRESS
75+
+ '","time":1652126648.5,"type":"news","content":{"title":"News 1"}}',
7076
content={
7177
"address": TEST_ADDRESS,
7278
"time": 1652126648.5,
@@ -84,7 +90,9 @@ def fixture_post_messages_with_types(
8490
signature="0x" + "0" * 128,
8591
item_type=ItemType.inline,
8692
type=MessageType.post,
87-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126649.5,"type":"tutorial","content":{"title":"Tutorial 1"}}',
93+
item_content='{"address":"'
94+
+ TEST_ADDRESS
95+
+ '","time":1652126649.5,"type":"tutorial","content":{"title":"Tutorial 1"}}',
8896
content={
8997
"address": TEST_ADDRESS,
9098
"time": 1652126649.5,
@@ -103,7 +111,9 @@ def fixture_post_messages_with_types(
103111
signature="0x" + "0" * 128,
104112
item_type=ItemType.inline,
105113
type=MessageType.aggregate,
106-
item_content='{"address":"' + TEST_ADDRESS + '","key":"test","time":1652126650.5,"content":{}}',
114+
item_content='{"address":"'
115+
+ TEST_ADDRESS
116+
+ '","key":"test","time":1652126650.5,"content":{}}',
107117
content={
108118
"address": TEST_ADDRESS,
109119
"key": "test",
@@ -293,7 +303,9 @@ def fixture_messages_with_channels(
293303
signature="0x" + "0" * 128,
294304
item_type=ItemType.inline,
295305
type=MessageType.post,
296-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126646.5,"type":"blog","content":{}}',
306+
item_content='{"address":"'
307+
+ TEST_ADDRESS
308+
+ '","time":1652126646.5,"type":"blog","content":{}}',
297309
content={
298310
"address": TEST_ADDRESS,
299311
"time": 1652126646.5,
@@ -311,7 +323,9 @@ def fixture_messages_with_channels(
311323
signature="0x" + "0" * 128,
312324
item_type=ItemType.inline,
313325
type=MessageType.post,
314-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126647.5,"type":"blog","content":{}}',
326+
item_content='{"address":"'
327+
+ TEST_ADDRESS
328+
+ '","time":1652126647.5,"type":"blog","content":{}}',
315329
content={
316330
"address": TEST_ADDRESS,
317331
"time": 1652126647.5,
@@ -329,7 +343,9 @@ def fixture_messages_with_channels(
329343
signature="0x" + "0" * 128,
330344
item_type=ItemType.inline,
331345
type=MessageType.aggregate,
332-
item_content='{"address":"' + TEST_ADDRESS + '","key":"test","time":1652126648.5,"content":{}}',
346+
item_content='{"address":"'
347+
+ TEST_ADDRESS
348+
+ '","key":"test","time":1652126648.5,"content":{}}',
333349
content={
334350
"address": TEST_ADDRESS,
335351
"key": "test",
@@ -347,7 +363,9 @@ def fixture_messages_with_channels(
347363
signature="0x" + "0" * 128,
348364
item_type=ItemType.inline,
349365
type=MessageType.store,
350-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126649.5,"item_hash":"hash123","item_type":"ipfs"}',
366+
item_content='{"address":"'
367+
+ TEST_ADDRESS
368+
+ '","time":1652126649.5,"item_hash":"hash123","item_type":"ipfs"}',
351369
content={
352370
"address": TEST_ADDRESS,
353371
"time": 1652126649.5,
@@ -366,7 +384,9 @@ def fixture_messages_with_channels(
366384
signature="0x" + "0" * 128,
367385
item_type=ItemType.inline,
368386
type=MessageType.post,
369-
item_content='{"address":"' + TEST_ADDRESS + '","time":1652126650.5,"type":"blog","content":{}}',
387+
item_content='{"address":"'
388+
+ TEST_ADDRESS
389+
+ '","time":1652126650.5,"type":"blog","content":{}}',
370390
content={
371391
"address": TEST_ADDRESS,
372392
"time": 1652126650.5,
@@ -594,4 +614,3 @@ async def test_get_account_channels_single_channel(
594614

595615
assert data["address"] == address
596616
assert data["channels"] == ["single_channel"]
597-

0 commit comments

Comments
 (0)