From 1a432947757fe8bf3cf4f834d64ef7f1ca30c756 Mon Sep 17 00:00:00 2001 From: Ray Okamoto Date: Tue, 14 Jan 2025 17:47:42 +1030 Subject: [PATCH 1/2] chore: linting and formatting fixes --- storb/challenge/__init__.py | 6 +++--- storb/miner/__main__.py | 3 +-- storb/util/message_signing.py | 1 - storb/util/uids.py | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/storb/challenge/__init__.py b/storb/challenge/__init__.py index fac069f..9048bc1 100644 --- a/storb/challenge/__init__.py +++ b/storb/challenge/__init__.py @@ -190,7 +190,7 @@ def serialize_prf_value(self, prf_value: bytes) -> str: return base64.b64encode(prf_value).decode("utf-8") @field_validator("prf_value", mode="before") - def deserialize_prf_value(cls, value): + def deserialize_prf_value(self, value): """Deserialize PRF value from base64.""" if isinstance(value, str): @@ -292,7 +292,7 @@ def serialize_prf_key(self, prf_key: bytes) -> str: return prf_key @field_validator("prf_key", mode="before") - def deserialize_prf_key(cls, value): + def deserialize_prf_key(self, value): """Deserialize PRF key from base64.""" if isinstance(value, str): @@ -304,7 +304,7 @@ def deserialize_prf_key(cls, value): return value @field_validator("prp_key", mode="before") - def deserialize_prp_key(cls, value): + def deserialize_prp_key(self, value): """Deserialize PRP key from base64.""" if isinstance(value, str): diff --git a/storb/miner/__main__.py b/storb/miner/__main__.py index 0be648a..53be9f8 100644 --- a/storb/miner/__main__.py +++ b/storb/miner/__main__.py @@ -1,9 +1,8 @@ import asyncio import time -from storb.util.logging import get_logger - from storb.miner import Miner +from storb.util.logging import get_logger logger = get_logger(__name__) diff --git a/storb/util/message_signing.py b/storb/util/message_signing.py index b82d48a..4bb63b0 100644 --- a/storb/util/message_signing.py +++ b/storb/util/message_signing.py @@ -1,5 +1,4 @@ from binascii import unhexlify -from typing import Union from pydantic import BaseModel from substrateinterface import Keypair diff --git a/storb/util/uids.py b/storb/util/uids.py index 44a1bc0..a8f8064 100644 --- a/storb/util/uids.py +++ b/storb/util/uids.py @@ -1,6 +1,5 @@ import random -import numpy as np from fiber.chain.metagraph import Metagraph from storb.neuron import Neuron From 4c09539f7a5c1a5f13489197d65a34e9e5ce79ec Mon Sep 17 00:00:00 2001 From: Ray Okamoto Date: Tue, 14 Jan 2025 17:47:56 +1030 Subject: [PATCH 2/2] ci: add linting and formatting workflow --- .github/workflows/ci-dev.yml | 20 +++++++++++++++ .github/workflows/lint-and-format.yml | 35 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/ci-dev.yml create mode 100644 .github/workflows/lint-and-format.yml diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml new file mode 100644 index 0000000..8a3f2ab --- /dev/null +++ b/.github/workflows/ci-dev.yml @@ -0,0 +1,20 @@ +name: Development +on: + pull_request: + branches: + - "**" + +jobs: + lint_and_format: + name: Linting and formatting checks + uses: ./.github/workflows/lint-and-format.yml + + # build: + # needs: lint_and_format + # name: Build + # runs-on: ubuntu-latest + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # # TODO diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml new file mode 100644 index 0000000..729d4a8 --- /dev/null +++ b/.github/workflows/lint-and-format.yml @@ -0,0 +1,35 @@ +name: Linting and formatting checks +on: + workflow_call: + +jobs: + lint_and_format: + name: Lint and Format + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + uv sync + + - name: Check for linting errors + run: | + uv run ruff check + + - name: Check formatting + run: | + uv run ruff format --check