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/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 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(