Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

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"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ check: ruff
@mypy --ignore-missing-imports bittensor/ --python-version=3.12
@mypy --ignore-missing-imports bittensor/ --python-version=3.13
@mypy --ignore-missing-imports bittensor/ --python-version=3.14
@flake8 bittensor/ --count
@python -m ruff check 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
3 changes: 0 additions & 3 deletions bittensor/utils/mock/subtensor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,6 @@ def _neuron_subnet_exists(
dividends = self._get_most_recent_storage(
subtensor_state["Dividends"][netuid][uid], block
)
pruning_score = self._get_most_recent_storage(
subtensor_state["PruningScores"][netuid][uid], block
)
last_update = self._get_most_recent_storage(
subtensor_state["LastUpdate"][netuid][uid], block
)
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
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "10.2.0"
description = "Bittensor SDK"
readme = "README.md"
authors = [
{name = "bittensor.com"}
{ name = "bittensor.com" }
]
license = { file = "LICENSE" }
requires-python = ">=3.10,<3.15"
Expand Down 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 Expand Up @@ -94,5 +93,11 @@ classifiers = [
]

[tool.setuptools]
package-dir = {"bittensor" = "bittensor"}
package-dir = { "bittensor" = "bittensor" }
script-files = ["bittensor/utils/certifi.sh"]

[tool.ruff]
exclude = [".git", "__pycache__", "__init__.py", "docs/source/conf.py", "old", "build", "dist", "venv", ".venv", ".tox"]

[tool.ruff.lint]
select = ["E9", "F63", "F7", "F82", "F401"]
1 change: 0 additions & 1 deletion tests/consistency/test_proxy_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from bittensor.core.chain_data.proxy import ProxyType
from bittensor.core.extrinsics.pallets import SubtensorModule, Proxy, Balances


def get_proxy_type_fields(meta):
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_crowdloan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from bittensor import Balance
from bittensor.core.extrinsics.pallets import SubtensorModule
from bittensor_wallet import Wallet
import pytest
import asyncio

Expand Down
6 changes: 0 additions & 6 deletions tests/e2e_tests/test_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from bittensor.core.chain_data.chain_identity import ChainIdentity
from bittensor.core.chain_data.delegate_info import DelegatedInfo, DelegateInfo
from bittensor.core.chain_data.proposal_vote_data import ProposalVoteData
from bittensor.core.errors import (
DelegateTakeTooHigh,
DelegateTxRateLimitExceeded,
Expand All @@ -11,13 +10,9 @@
)
from bittensor.utils.balance import Balance
from tests.e2e_tests.utils import (
async_propose,
async_set_identity,
async_vote,
get_dynamic_balance,
propose,
set_identity,
vote,
TestSubnet,
AdminUtils,
ACTIVATE_SUBNET,
Expand All @@ -26,7 +21,6 @@
SUDO_SET_NOMINATOR_MIN_REQUIRED_STAKE,
SUDO_SET_TX_DELEGATE_TAKE_RATE_LIMIT,
)
from tests.helpers.helpers import CloseInValue

DEFAULT_DELEGATE_TAKE = 0.179995422293431

Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_incentive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest

from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging
from tests.e2e_tests.utils import (
TestSubnet,
AdminUtils,
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging
from bittensor.utils.registration.pow import LazyLoadedTorch
from bittensor.utils.weight_utils import convert_and_normalize_weights_and_uids
from tests.e2e_tests.utils import (
AdminUtils,
NETUID,
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_subnets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
from bittensor.utils.btlogging import logging


def test_subnets(subtensor, alice_wallet):
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e_tests/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import pytest

from bittensor.utils.balance import Balance
from bittensor import logging

if typing.TYPE_CHECKING:
from bittensor.extras import SubtensorApi
pass


def test_transfer(subtensor, alice_wallet):
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/utils/e2e_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Optional
from bittensor_wallet import Keypair, Wallet

from bittensor.extras import SubtensorApi
from bittensor.utils.btlogging import logging

template_path = os.getcwd() + "/neurons/"
Expand Down
3 changes: 0 additions & 3 deletions tests/unit_tests/extrinsics/asyncex/test_coldkey_swap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import pytest
from bittensor_wallet import Wallet
from scalecodec.types import GenericCall

from bittensor.core.extrinsics.asyncex import coldkey_swap
from bittensor.core.extrinsics.pallets import SubtensorModule
from bittensor.core.settings import DEFAULT_MEV_PROTECTION
from bittensor.core.types import ExtrinsicResponse
from bittensor.core.chain_data.coldkey_swap import ColdkeySwapAnnouncementInfo

Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/extrinsics/asyncex/test_weights.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from bittensor.core.extrinsics.asyncex import weights as weights_module
from bittensor.core.settings import version_as_int
from bittensor.core.types import ExtrinsicResponse


Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/extrinsics/test_mev_shield.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from bittensor_wallet import Wallet
from scalecodec.types import GenericCall
from async_substrate_interface import ExtrinsicReceipt
from async_substrate_interface.errors import SubstrateRequestException
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/extrinsics/test_transfer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from bittensor.core.extrinsics import transfer
from bittensor.core.settings import DEFAULT_MEV_PROTECTION
from bittensor.utils.balance import Balance
Expand Down
4 changes: 1 addition & 3 deletions tests/unit_tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"""

import pytest
from abc import ABC
from typing import Optional
from unittest.mock import AsyncMock, Mock, MagicMock, patch
from unittest.mock import AsyncMock, Mock
from aiohttp import ClientResponse
from starlette.types import Send, Receive, Scope

Expand Down
Loading