From 4b496b33263b24a8600d7ab8e290bf01deb6c1a5 Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Wed, 22 Oct 2025 22:03:07 +0200 Subject: [PATCH 1/3] ci: run linter on PRs The linter was not running on PRs, resulting in failing checks after merging PRs. --- .github/workflows/code-quality.yml | 4 ++++ src/aleph/chains/avalanche.py | 2 +- src/aleph/chains/nuls_aleph_sdk.py | 2 +- src/aleph/db/accessors/peers.py | 4 +++- src/aleph/jobs/reconnect_ipfs.py | 2 +- src/aleph/services/p2p/http.py | 2 +- src/aleph/services/pricing_utils.py | 2 +- src/aleph/storage.py | 2 +- src/aleph/toolkit/timestamp.py | 2 +- tests/api/conftest.py | 2 +- tests/db/test_peers.py | 5 +++-- 11 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index d63547f5a..a8c5c332b 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -4,6 +4,10 @@ name: Test code quality on: push: + branches: + - dev + - main + pull_request: branches: - "*" diff --git a/src/aleph/chains/avalanche.py b/src/aleph/chains/avalanche.py index 12e2ca217..c85e1774c 100644 --- a/src/aleph/chains/avalanche.py +++ b/src/aleph/chains/avalanche.py @@ -13,7 +13,7 @@ LOGGER = logging.getLogger("chains.avalanche") CHAIN_NAME = "AVAX" -MESSAGE_TEMPLATE = b"\x1AAvalanche Signed Message:\n%b" +MESSAGE_TEMPLATE = b"\x1aAvalanche Signed Message:\n%b" async def pack_message(message): diff --git a/src/aleph/chains/nuls_aleph_sdk.py b/src/aleph/chains/nuls_aleph_sdk.py index 7c17257c4..4082b2457 100644 --- a/src/aleph/chains/nuls_aleph_sdk.py +++ b/src/aleph/chains/nuls_aleph_sdk.py @@ -12,7 +12,7 @@ LOGGER = logging.getLogger(__name__) -PLACE_HOLDER = b"\xFF\xFF\xFF\xFF" +PLACE_HOLDER = b"\xff\xff\xff\xff" B58_DIGITS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" MESSAGE_TEMPLATE = "\x18NULS Signed Message:\n{}" diff --git a/src/aleph/db/accessors/peers.py b/src/aleph/db/accessors/peers.py index f02b3f612..8599b51d6 100644 --- a/src/aleph/db/accessors/peers.py +++ b/src/aleph/db/accessors/peers.py @@ -11,7 +11,9 @@ def get_all_addresses_by_peer_type( - session: DbSession, peer_type: PeerType, last_seen: Optional[dt.datetime] = None, + session: DbSession, + peer_type: PeerType, + last_seen: Optional[dt.datetime] = None, ) -> Sequence[str]: """ Fetches all peer addresses filtered by peer type and optionally by the last_seen diff --git a/src/aleph/jobs/reconnect_ipfs.py b/src/aleph/jobs/reconnect_ipfs.py index 5c4a80d18..57f68d9dc 100644 --- a/src/aleph/jobs/reconnect_ipfs.py +++ b/src/aleph/jobs/reconnect_ipfs.py @@ -18,7 +18,7 @@ async def reconnect_ipfs_job( - config: Config, session_factory: DbSessionFactory, ipfs_service: IpfsService + config: Config, session_factory: DbSessionFactory, ipfs_service: IpfsService ): from aleph.services.utils import get_IP diff --git a/src/aleph/services/p2p/http.py b/src/aleph/services/p2p/http.py index 53b92d537..36ed55315 100644 --- a/src/aleph/services/p2p/http.py +++ b/src/aleph/services/p2p/http.py @@ -1,4 +1,4 @@ -""" While our own streamer libp2p protocol is still unstable, use direct +"""While our own streamer libp2p protocol is still unstable, use direct HTTP connection to standard rest API. """ diff --git a/src/aleph/services/pricing_utils.py b/src/aleph/services/pricing_utils.py index 11c1975cd..e0f9a0779 100644 --- a/src/aleph/services/pricing_utils.py +++ b/src/aleph/services/pricing_utils.py @@ -20,7 +20,7 @@ def build_pricing_model_from_aggregate( - aggregate_content: Dict[Union[ProductPriceType, str], dict] + aggregate_content: Dict[Union[ProductPriceType, str], dict], ) -> Dict[ProductPriceType, ProductPricing]: """ Build a complete pricing model from an aggregate content dictionary. diff --git a/src/aleph/storage.py b/src/aleph/storage.py index d9a4d19f2..89e3c8913 100644 --- a/src/aleph/storage.py +++ b/src/aleph/storage.py @@ -1,4 +1,4 @@ -""" Storage module for Aleph. +"""Storage module for Aleph. Basically manages the IPFS storage. """ diff --git a/src/aleph/toolkit/timestamp.py b/src/aleph/toolkit/timestamp.py index 8fae474c5..7facb1dfc 100644 --- a/src/aleph/toolkit/timestamp.py +++ b/src/aleph/toolkit/timestamp.py @@ -14,7 +14,7 @@ def timestamp_to_datetime(timestamp: float) -> dt.datetime: def coerce_to_datetime( - datetime_or_timestamp: Optional[Union[float, dt.datetime]] + datetime_or_timestamp: Optional[Union[float, dt.datetime]], ) -> Optional[dt.datetime]: # None for datetimes or 0 for timestamps results in returning None if datetime_or_timestamp is None or not datetime_or_timestamp: diff --git a/tests/api/conftest.py b/tests/api/conftest.py index 79e95d30d..268e12aea 100644 --- a/tests/api/conftest.py +++ b/tests/api/conftest.py @@ -182,7 +182,7 @@ def post_with_refs_and_tags() -> Tuple[MessageDb, PostDb, MessageStatusDb]: @pytest.fixture def amended_post_with_refs_and_tags( - post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb] + post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], ): original_message, original_post, _ = post_with_refs_and_tags diff --git a/tests/db/test_peers.py b/tests/db/test_peers.py index 2d6b31f55..6804b2775 100644 --- a/tests/db/test_peers.py +++ b/tests/db/test_peers.py @@ -63,13 +63,14 @@ async def test_get_all_addresses_by_peer_type(session_factory: DbSessionFactory) session=session, peer_type=PeerType.P2P, last_seen=last_seen ) old_p2p_entries = get_all_addresses_by_peer_type( - session=session, peer_type=PeerType.P2P, last_seen=last_seen + dt.timedelta(days=1) + session=session, + peer_type=PeerType.P2P, + last_seen=last_seen + dt.timedelta(days=1), ) assert recent_p2p_entries == [p2p_entry.address] assert old_p2p_entries == [] - @pytest.mark.asyncio @pytest.mark.parametrize("peer_type", (PeerType.HTTP, PeerType.P2P, PeerType.IPFS)) async def test_get_all_addresses_by_peer_type_no_match( From b475e966be4ce97664bc245b29b538984ccc255b Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Wed, 22 Oct 2025 22:05:55 +0200 Subject: [PATCH 2/3] isort --- src/aleph/db/accessors/posts.py | 7 ++++++- src/aleph/handlers/content/post.py | 8 ++++++-- src/aleph/services/p2p/jobs.py | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/aleph/db/accessors/posts.py b/src/aleph/db/accessors/posts.py index cc1b8f57f..33f05536d 100644 --- a/src/aleph/db/accessors/posts.py +++ b/src/aleph/db/accessors/posts.py @@ -13,7 +13,12 @@ ) from aleph_message.models import Chain, ItemHash, ItemType -from sqlalchemy import TIMESTAMP, Float, String, case +from sqlalchemy import ( + TIMESTAMP, + Float, + String, + case, +) from sqlalchemy import cast as sqla_cast from sqlalchemy import ( delete, diff --git a/src/aleph/handlers/content/post.py b/src/aleph/handlers/content/post.py index dcc344283..b29201778 100644 --- a/src/aleph/handlers/content/post.py +++ b/src/aleph/handlers/content/post.py @@ -5,7 +5,9 @@ from aleph_message.models import Chain, ChainRef, PostContent from sqlalchemy import update -from aleph.db.accessors.balances import get_credit_balance +from aleph.db.accessors.balances import ( + get_credit_balance, +) from aleph.db.accessors.balances import update_balances as update_balances_db from aleph.db.accessors.balances import ( update_credit_balances_distribution as update_credit_balances_distribution_db, @@ -16,7 +18,9 @@ from aleph.db.accessors.balances import ( update_credit_balances_transfer as update_credit_balances_transfer_db, ) -from aleph.db.accessors.balances import validate_credit_transfer_balance +from aleph.db.accessors.balances import ( + validate_credit_transfer_balance, +) from aleph.db.accessors.posts import ( delete_amends, delete_post, diff --git a/src/aleph/services/p2p/jobs.py b/src/aleph/services/p2p/jobs.py index 68cb06349..68a06e6cf 100644 --- a/src/aleph/services/p2p/jobs.py +++ b/src/aleph/services/p2p/jobs.py @@ -10,9 +10,10 @@ from aleph.db.accessors.peers import get_all_addresses_by_peer_type from aleph.db.models import PeerType from aleph.types.db_session import DbSessionFactory + +from ..cache.node_cache import NodeCache from .http import api_get_request from .peers import connect_peer -from ..cache.node_cache import NodeCache @dataclass From 42008e95d876d60f0722813300f4701d21c7877b Mon Sep 17 00:00:00 2001 From: Olivier Desenfans Date: Wed, 22 Oct 2025 22:09:04 +0200 Subject: [PATCH 3/3] isort again --- src/aleph/db/accessors/posts.py | 7 +------ src/aleph/handlers/content/post.py | 8 ++------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/aleph/db/accessors/posts.py b/src/aleph/db/accessors/posts.py index 33f05536d..cc1b8f57f 100644 --- a/src/aleph/db/accessors/posts.py +++ b/src/aleph/db/accessors/posts.py @@ -13,12 +13,7 @@ ) from aleph_message.models import Chain, ItemHash, ItemType -from sqlalchemy import ( - TIMESTAMP, - Float, - String, - case, -) +from sqlalchemy import TIMESTAMP, Float, String, case from sqlalchemy import cast as sqla_cast from sqlalchemy import ( delete, diff --git a/src/aleph/handlers/content/post.py b/src/aleph/handlers/content/post.py index b29201778..dcc344283 100644 --- a/src/aleph/handlers/content/post.py +++ b/src/aleph/handlers/content/post.py @@ -5,9 +5,7 @@ from aleph_message.models import Chain, ChainRef, PostContent from sqlalchemy import update -from aleph.db.accessors.balances import ( - get_credit_balance, -) +from aleph.db.accessors.balances import get_credit_balance from aleph.db.accessors.balances import update_balances as update_balances_db from aleph.db.accessors.balances import ( update_credit_balances_distribution as update_credit_balances_distribution_db, @@ -18,9 +16,7 @@ from aleph.db.accessors.balances import ( update_credit_balances_transfer as update_credit_balances_transfer_db, ) -from aleph.db.accessors.balances import ( - validate_credit_transfer_balance, -) +from aleph.db.accessors.balances import validate_credit_transfer_balance from aleph.db.accessors.posts import ( delete_amends, delete_post,