diff --git a/compute_horde/compute_horde/test_base/__init__.py b/compute_horde/compute_horde/test_base/__init__.py index a8b9c069c..8168e809d 100644 --- a/compute_horde/compute_horde/test_base/__init__.py +++ b/compute_horde/compute_horde/test_base/__init__.py @@ -105,7 +105,7 @@ def start_process(cls, args, additional_env: dict[str, str]): @classmethod def wait_for_process_start(cls, process_name, probe_function, process: subprocess.Popen): - for i in range(300): + for _ in range(300): if probe_function(): return if process.poll() is not None: diff --git a/compute_horde/pyproject.toml b/compute_horde/pyproject.toml index 3de5a52fc..a625eb0ba 100644 --- a/compute_horde/pyproject.toml +++ b/compute_horde/pyproject.toml @@ -55,17 +55,18 @@ line-length = 100 [tool.ruff.lint] # TODO add D -select = ["E", "F", "I", "UP"] +select = ["E", "F", "I", "UP", "B"] # TODO: remove E501 once docstrings are formatted ignore = [ "D100", "D105", "D107", "D200", "D202", "D203", "D205", "D212", "D400", "D401", "D415", "D101", "D102","D103", "D104", # TODO remove once we have docstring for all public methods "E501", # TODO: remove E501 once docstrings are formatted + "B027", "B904", "B905", ] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"test/**" = ["D", "F403", "F405"] +"**/tests/**" = ["D", "F403", "F405", "B018"] [tool.codespell] skip = 'pdm.lock' diff --git a/executor/bin/rotate-local-backups.py b/executor/bin/rotate-local-backups.py index 44eff24c6..57f47801f 100755 --- a/executor/bin/rotate-local-backups.py +++ b/executor/bin/rotate-local-backups.py @@ -18,7 +18,7 @@ def rotate_backups(path, file_count): files = files[:-file_count] if files: print(f"Removing {len(files)} old files") - for mtime, f in files: + for _mtime, f in files: f.unlink() else: print("No old files to remove") diff --git a/executor/pyproject.toml b/executor/pyproject.toml index da19a10a4..84c34d330 100644 --- a/executor/pyproject.toml +++ b/executor/pyproject.toml @@ -69,17 +69,18 @@ line-length = 100 [tool.ruff.lint] # TODO add D -select = ["E", "F", "I", "UP"] +select = ["E", "F", "I", "UP", "B"] # TODO: remove E501 once docstrings are formatted ignore = [ "D100", "D105", "D107", "D200", "D202", "D203", "D205", "D212", "D400", "D401", "D415", "D101", "D102","D103", "D104", # TODO remove once we have docstring for all public methods "E501", # TODO: remove E501 once docstrings are formatted + "B027", "B904", "B905", ] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"test/**" = ["D", "F403", "F405"] +"**/tests/**" = ["D", "F403", "F405", "B018"] [tool.codespell] skip = '*.min.js,*.lock,*/monitoring_certs/*' diff --git a/miner/bin/rotate-local-backups.py b/miner/bin/rotate-local-backups.py index 44eff24c6..57f47801f 100755 --- a/miner/bin/rotate-local-backups.py +++ b/miner/bin/rotate-local-backups.py @@ -18,7 +18,7 @@ def rotate_backups(path, file_count): files = files[:-file_count] if files: print(f"Removing {len(files)} old files") - for mtime, f in files: + for _mtime, f in files: f.unlink() else: print("No old files to remove") diff --git a/miner/pyproject.toml b/miner/pyproject.toml index 181621c72..359e55393 100644 --- a/miner/pyproject.toml +++ b/miner/pyproject.toml @@ -70,17 +70,18 @@ line-length = 100 [tool.ruff.lint] # TODO add D -select = ["E", "F", "I", "UP"] +select = ["E", "F", "I", "UP", "B"] # TODO: remove E501 once docstrings are formatted ignore = [ "D100", "D105", "D107", "D200", "D202", "D203", "D205", "D212", "D400", "D401", "D415", "D101", "D102","D103", "D104", # TODO remove once we have docstring for all public methods "E501", # TODO: remove E501 once docstrings are formatted + "B027", "B904", "B905", ] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"test/**" = ["D", "F403", "F405"] +"**/tests/**" = ["D", "F403", "F405", "B018"] [tool.codespell] skip = '*.min.js,*.lock,*/monitoring_certs/*' diff --git a/validator/app/src/compute_horde_validator/validator/organic_jobs/facilitator_client.py b/validator/app/src/compute_horde_validator/validator/organic_jobs/facilitator_client.py index b9a12ebdc..d9ccf1baf 100644 --- a/validator/app/src/compute_horde_validator/validator/organic_jobs/facilitator_client.py +++ b/validator/app/src/compute_horde_validator/validator/organic_jobs/facilitator_client.py @@ -41,12 +41,14 @@ def __init__(self, reason: str, errors: list[Error]): self.errors = errors -async def save_facilitator_event(subtype: str, long_description: str, data={}, success=False): +async def save_facilitator_event( + subtype: str, long_description: str, data: dict[str, str] | None = None, success=False +): await SystemEvent.objects.using(settings.DEFAULT_DB_ALIAS).acreate( type=SystemEvent.EventType.FACILITATOR_CLIENT_ERROR, subtype=subtype, long_description=long_description, - data=data, + data=data or {}, ) diff --git a/validator/app/src/compute_horde_validator/validator/tests/helpers.py b/validator/app/src/compute_horde_validator/validator/tests/helpers.py index 2bb5429d6..b222779e2 100644 --- a/validator/app/src/compute_horde_validator/validator/tests/helpers.py +++ b/validator/app/src/compute_horde_validator/validator/tests/helpers.py @@ -208,11 +208,7 @@ def __init__( mocked_commit_weights=lambda: (True, ""), mocked_reveal_weights=lambda: (True, ""), mocked_metagraph=lambda: MockMetagraph(), - hyperparameters=MockHyperparameters( - commit_reveal_weights_enabled=False, - commit_reveal_weights_interval=1000, - max_weight_limit=65535, - ), + hyperparameters=None, block_duration=timedelta(seconds=1), override_block_number=None, increase_block_number_with_each_call=False, @@ -222,7 +218,11 @@ def __init__( self.mocked_commit_weights = mocked_commit_weights self.mocked_reveal_weights = mocked_reveal_weights self.mocked_metagraph = mocked_metagraph - self.hyperparameters = hyperparameters + self.hyperparameters = hyperparameters or MockHyperparameters( + commit_reveal_weights_enabled=False, + commit_reveal_weights_interval=1000, + max_weight_limit=65535, + ) self.weights_set: list[list[numbers.Number]] = [] self.weights_committed: list[list[numbers.Number]] = [] self.weights_revealed: list[list[numbers.Number]] = [] diff --git a/validator/app/src/compute_horde_validator/validator/tests/test_commands.py b/validator/app/src/compute_horde_validator/validator/tests/test_commands.py index ffd7bc490..5de274d70 100644 --- a/validator/app/src/compute_horde_validator/validator/tests/test_commands.py +++ b/validator/app/src/compute_horde_validator/validator/tests/test_commands.py @@ -85,7 +85,7 @@ def test_debug_run_organic_job_command__job_not_created(): Miner.objects.create(hotkey="miner_client") with redirect_stdout(io.StringIO()) as buf: - with pytest.raises(BaseException): + with pytest.raises(SystemExit): management.call_command( "debug_run_organic_job", docker_image="noop", timeout=4, cmd_args="" ) diff --git a/validator/app/src/compute_horde_validator/validator/tests/test_facilitator_client.py b/validator/app/src/compute_horde_validator/validator/tests/test_facilitator_client.py index 149deb07e..9b7175837 100644 --- a/validator/app/src/compute_horde_validator/validator/tests/test_facilitator_client.py +++ b/validator/app/src/compute_horde_validator/validator/tests/test_facilitator_client.py @@ -150,7 +150,7 @@ async def test_facilitator_client(ws_server_cls): facilitator_client.specs_task.cancel() task.cancel() if ws_server.facilitator_error: - assert False, ws_server.facilitator_error + pytest.fail(str(ws_server.facilitator_error)) @pytest.fixture diff --git a/validator/app/src/compute_horde_validator/validator/tests/test_utils.py b/validator/app/src/compute_horde_validator/validator/tests/test_utils.py index 1d6624fe2..68a83957c 100644 --- a/validator/app/src/compute_horde_validator/validator/tests/test_utils.py +++ b/validator/app/src/compute_horde_validator/validator/tests/test_utils.py @@ -468,7 +468,7 @@ async def interaction_callback(miner_client, after_job_sent): miner_client = mocked_synthetic_miner_client.instance async for job in SyntheticJob.objects.filter(job_uuid__in=job_uuids): receipt = miner_client._query_sent_models( - lambda m: m.payload.job_uuid == str(job.job_uuid), V0JobFinishedReceiptRequest + lambda m, j=job: m.payload.job_uuid == str(j.job_uuid), V0JobFinishedReceiptRequest )[0] time_took = receipt.payload.time_took_us / 1_000_000 assert abs(job.score * time_took - expected_multiplier) < 0.0001 @@ -555,7 +555,7 @@ async def interaction_callback(miner_client, after_job_sent): miner_client = mocked_synthetic_miner_client.instance for job in SyntheticJob.objects.filter(job_uuid__in=job_uuids): receipt = miner_client._query_sent_models( - lambda m: m.payload.job_uuid == str(job.job_uuid), V0JobFinishedReceiptRequest + lambda m, j=job: m.payload.job_uuid == str(j.job_uuid), V0JobFinishedReceiptRequest )[0] time_took = receipt.payload.time_took_us / 1_000_000 assert abs(job.score * time_took - expected_multiplier) < 0.0001 diff --git a/validator/bin/rotate-local-backups.py b/validator/bin/rotate-local-backups.py index 44eff24c6..57f47801f 100755 --- a/validator/bin/rotate-local-backups.py +++ b/validator/bin/rotate-local-backups.py @@ -18,7 +18,7 @@ def rotate_backups(path, file_count): files = files[:-file_count] if files: print(f"Removing {len(files)} old files") - for mtime, f in files: + for _mtime, f in files: f.unlink() else: print("No old files to remove") diff --git a/validator/pyproject.toml b/validator/pyproject.toml index 7afe8db5a..3fcc69dca 100644 --- a/validator/pyproject.toml +++ b/validator/pyproject.toml @@ -77,7 +77,7 @@ line-length = 100 [tool.ruff.lint] # TODO add D select = [ - "E", "F", "I", "UP", + "E", "F", "I", "UP", "B", "TCH005", ] # TODO: remove E501 once docstrings are formatted @@ -85,11 +85,12 @@ ignore = [ "D100", "D105", "D107", "D200", "D202", "D203", "D205", "D212", "D400", "D401", "D415", "D101", "D102","D103", "D104", # TODO remove once we have docstring for all public methods "E501", # TODO: remove E501 once docstrings are formatted + "B027", "B904", "B905", ] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"test/**" = ["D", "F403", "F405"] +"**/tests/**" = ["D", "F403", "F405", "B018"] [tool.codespell] skip = '*.min.js,*.lock,*/monitoring_certs/*'