Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/flake8-and-mypy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Flake8 and Mypy - linters check
name: Mypy check
permissions:
contents: read

Expand Down Expand Up @@ -55,8 +55,5 @@ jobs:
- name: Sync dev deps
run: uv sync --extra dev --dev

- name: Flake8
run: uv run flake8 bittensor/ --count

- name: Mypy
run: uv run mypy --ignore-missing-imports bittensor/
30 changes: 13 additions & 17 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruff - formatter check
name: Ruff - formatter/linter check
permissions:
contents: read

Expand All @@ -8,26 +8,22 @@ on:

jobs:
ruff:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
- name: Ruff format check
uses: astral-sh/ruff-action@v4.0.0
with:
python-version: "3.11"

- name: Install Ruff in virtual environment
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install ruff==0.11.5
version: "0.11.5"
args: "format --diff"
src: "bittensor tests"

- name: Ruff format check
run: |
source venv/bin/activate
python -m ruff format --diff bittensor
- name: Ruff linter check
uses: astral-sh/ruff-action@v4.0.0
with:
version: "0.11.5"
args: "check"
src: "bittensor"
10 changes: 7 additions & 3 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from .core.settings import __version__, DEFAULTS, DEFAULT_NETWORK
from .utils.btlogging import logging
from .utils.easy_imports import *
from .core.settings import (
__version__ as __version__,
DEFAULTS as DEFAULTS,
DEFAULT_NETWORK as DEFAULT_NETWORK,
)
from .utils.btlogging import logging # noqa: F401
from .utils.easy_imports import * # noqa: F403
4 changes: 2 additions & 2 deletions bittensor/core/extrinsics/asyncex/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ async def register_extrinsic(
if not torch.cuda.is_available():
return ExtrinsicResponse(False, "CUDA not available.").with_log()

logging.debug(f"Creating a POW with CUDA.")
logging.debug("Creating a POW with CUDA.")
pow_result = await create_pow_async(
subtensor=subtensor,
wallet=wallet,
Expand All @@ -355,7 +355,7 @@ async def register_extrinsic(
log_verbose=log_verbose,
)
else:
logging.debug(f"Creating a POW.")
logging.debug("Creating a POW.")
pow_result = await create_pow_async(
subtensor=subtensor,
wallet=wallet,
Expand Down
4 changes: 2 additions & 2 deletions bittensor/core/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def register_extrinsic(
if not torch.cuda.is_available():
return ExtrinsicResponse(False, "CUDA not available.").with_log()

logging.debug(f"Creating a POW with CUDA.")
logging.debug("Creating a POW with CUDA.")
pow_result = create_pow(
subtensor=subtensor,
wallet=wallet,
Expand All @@ -347,7 +347,7 @@ def register_extrinsic(
log_verbose=log_verbose,
)
else:
logging.debug(f"Creating a POW.")
logging.debug("Creating a POW.")
pow_result = create_pow(
subtensor=subtensor,
wallet=wallet,
Expand Down
10 changes: 5 additions & 5 deletions bittensor/core/extrinsics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ def apply_pure_proxy_data(
# If triggered events are not available or event PureCreated does not exist in the response, return the response
# with warning message ot raise the error if raise_error is True.
message = (
f"The ExtrinsicResponse doesn't contain pure_proxy data (`pure_account`, `spawner`, `proxy_type`, etc.) "
f"because the extrinsic receipt doesn't have triggered events. This typically happens when "
f"`wait_for_inclusion=False` or when `block_hash` is not available. To get this data, either pass "
f"`wait_for_inclusion=True` when calling this function, or retrieve the data manually from the blockchain "
f"using the extrinsic hash."
"The ExtrinsicResponse doesn't contain pure_proxy data (`pure_account`, `spawner`, `proxy_type`, etc.) "
"because the extrinsic receipt doesn't have triggered events. This typically happens when "
"`wait_for_inclusion=False` or when `block_hash` is not available. To get this data, either pass "
"`wait_for_inclusion=True` when calling this function, or retrieve the data manually from the blockchain "
"using the extrinsic hash."
)
if response.extrinsic is not None and hasattr(response.extrinsic, "extrinsic_hash"):
extrinsic_hash = response.extrinsic.extrinsic_hash
Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def S(self) -> Tensor:
return self.stake

@property
def I(self) -> Tensor:
def I(self) -> Tensor: # noqa: E743
"""
Incentive values of neurons represent the rewards they receive for their contributions to the network.
The Bittensor network employs an incentive mechanism that rewards neurons based on their
Expand Down
12 changes: 6 additions & 6 deletions bittensor/extras/dev_framework/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .calls import * # noqa: F401
from .calls import * # noqa: F403
from .subnet import (
NETUID,
TestSubnet,
ACTIVATE_SUBNET,
REGISTER_SUBNET,
REGISTER_NEURON,
NETUID as NETUID,
TestSubnet as TestSubnet,
ACTIVATE_SUBNET as ACTIVATE_SUBNET,
REGISTER_SUBNET as REGISTER_SUBNET,
REGISTER_NEURON as REGISTER_NEURON,
)
6 changes: 3 additions & 3 deletions bittensor/extras/dev_framework/calls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import os
from bittensor import Subtensor
from bittensor.extras.dev_framework.calls.sudo_calls import * # noqa: F401
from bittensor.extras.dev_framework.calls.non_sudo_calls import * # noqa: F401
from bittensor.extras.dev_framework.calls.pallets import * # noqa: F401
from bittensor.extras.dev_framework.calls.sudo_calls import * # noqa: F403
from bittensor.extras.dev_framework.calls.non_sudo_calls import * # noqa: F403
from bittensor.extras.dev_framework.calls.pallets import * # noqa: F403

HEADER = '''"""
This file is auto-generated. Do not edit manually.
Expand Down
2 changes: 1 addition & 1 deletion bittensor/extras/dev_framework/subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from bittensor.core.types import ExtrinsicResponse
from bittensor.extras import SubtensorApi
from bittensor.utils.btlogging import logging
from .calls import * # noqa: F401#
from .calls import * # noqa: F403
from .utils import (
is_instance_namedtuple,
split_command,
Expand Down
1 change: 0 additions & 1 deletion bittensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
if TYPE_CHECKING:
from bittensor_wallet import Wallet
from bittensor.core.types import ExtrinsicResponse
from bittensor.utils.balance import Balance

# keep save from import analyzer as obvious aliases
hex_to_ss58 = ss58_encode
Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/btlogging/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

BASE_LOG_FORMAT = "%(asctime)s | %(levelname)s | %(message)s"
TRACE_LOG_FORMAT = (
f"%(asctime)s | %(levelname)s | %(name)s:%(filename)s:%(lineno)s | %(message)s"
"%(asctime)s | %(levelname)s | %(name)s:%(filename)s:%(lineno)s | %(message)s"
)
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
BITTENSOR_LOGGER_NAME = "bittensor"
Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/mock/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .subtensor_mock import MockSubtensor
from .subtensor_mock import MockSubtensor as MockSubtensor
2 changes: 1 addition & 1 deletion bittensor/utils/mock/subtensor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def _neuron_subnet_exists(
dividends = self._get_most_recent_storage(
subtensor_state["Dividends"][netuid][uid], block
)
pruning_score = self._get_most_recent_storage(
pruning_score = self._get_most_recent_storage( # noqa
subtensor_state["PruningScores"][netuid][uid], block
)
last_update = self._get_most_recent_storage(
Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def check_latest_version_in_pypi():
except InvalidVersion:
# stay silent if InvalidVersion
pass
except (requests.RequestException, KeyError) as e:
except (requests.RequestException, KeyError):
# stay silent if not internet connection or pypi.org issue
pass
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ dev = [
"pytest-cov==4.0.0",
"ddt==1.6.0",
"hypothesis==6.81.1",
"flake8==7.0.0",
"mypy==1.8.0",
"types-retry==0.9.9.4",
"typing_extensions>= 4.0.0; python_version<'3.11'",
Expand Down
Loading