Skip to content

build(deps): bump ruff from 0.9.6 to 0.11.4 #19482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2025
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
56 changes: 28 additions & 28 deletions chia/_tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async def test_long_chain(self, empty_blockchain: Blockchain, default_1000_block
uint64(10_000_000),
)
block_bad = recursive_replace(
block, "finished_sub_slots", [new_finished_ss] + block.finished_sub_slots[1:]
block, "finished_sub_slots", [new_finished_ss, *block.finished_sub_slots[1:]]
)
header_block_bad = get_block_header(block_bad)
# TODO: Inspect these block values as they are currently None
Expand All @@ -196,7 +196,7 @@ async def test_long_chain(self, empty_blockchain: Blockchain, default_1000_block
uint64(10_000_000),
)
block_bad_2 = recursive_replace(
block, "finished_sub_slots", [new_finished_ss_2] + block.finished_sub_slots[1:]
block, "finished_sub_slots", [new_finished_ss_2, *block.finished_sub_slots[1:]]
)

header_block_bad_2 = get_block_header(block_bad_2)
Expand Down Expand Up @@ -510,7 +510,7 @@ async def test_invalid_sub_slot_challenge_hash_genesis(self, empty_blockchain: B
bytes([2] * 32),
)
block_0_bad = recursive_replace(
blocks[0], "finished_sub_slots", [new_finished_ss] + blocks[0].finished_sub_slots[1:]
blocks[0], "finished_sub_slots", [new_finished_ss, *blocks[0].finished_sub_slots[1:]]
)

header_block_bad = get_block_header(block_0_bad)
Expand Down Expand Up @@ -538,7 +538,7 @@ async def test_invalid_sub_slot_challenge_hash_non_genesis(
bytes([2] * 32),
)
block_1_bad = recursive_replace(
blocks[1], "finished_sub_slots", [new_finished_ss] + blocks[1].finished_sub_slots[1:]
blocks[1], "finished_sub_slots", [new_finished_ss, *blocks[1].finished_sub_slots[1:]]
)

await _validate_and_add_block(empty_blockchain, blocks[0])
Expand All @@ -565,7 +565,7 @@ async def test_invalid_sub_slot_challenge_hash_empty_ss(self, empty_blockchain:
bytes([2] * 32),
)
block_1_bad = recursive_replace(
blocks[1], "finished_sub_slots", blocks[1].finished_sub_slots[:-1] + [new_finished_ss]
blocks[1], "finished_sub_slots", [*blocks[1].finished_sub_slots[:-1], new_finished_ss]
)
await _validate_and_add_block(empty_blockchain, blocks[0])

Expand Down Expand Up @@ -597,7 +597,7 @@ async def test_genesis_no_icc(self, empty_blockchain: Blockchain, bt: BlockTools
),
)
block_0_bad = recursive_replace(
blocks[0], "finished_sub_slots", [new_finished_ss] + blocks[0].finished_sub_slots[1:]
blocks[0], "finished_sub_slots", [new_finished_ss, *blocks[0].finished_sub_slots[1:]]
)
await _validate_and_add_block(empty_blockchain, block_0_bad, expected_error=Err.SHOULD_NOT_HAVE_ICC)

Expand Down Expand Up @@ -631,7 +631,7 @@ async def do_test_invalid_icc_sub_slot_vdf(
),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss]
)
await _validate_and_add_block(bc1, block_bad, expected_error=Err.INVALID_ICC_EOS_VDF)

Expand All @@ -649,7 +649,7 @@ async def do_test_invalid_icc_sub_slot_vdf(
)
log.warning(f"Proof: {block.finished_sub_slots[-1].proofs}")
block_bad_2 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_2]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_2]
)
await _validate_and_add_block(bc1, block_bad_2, expected_error=Err.INVALID_ICC_EOS_VDF)

Expand All @@ -666,7 +666,7 @@ async def do_test_invalid_icc_sub_slot_vdf(
),
)
block_bad_3 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_3]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_3]
)
await _validate_and_add_block(bc1, block_bad_3, expected_error=Err.INVALID_ICC_EOS_VDF)

Expand All @@ -677,7 +677,7 @@ async def do_test_invalid_icc_sub_slot_vdf(
VDFProof(uint8(0), b"1239819023890", False),
)
block_bad_5 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_5]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_5]
)
await _validate_and_add_block(bc1, block_bad_5, expected_error=Err.INVALID_ICC_EOS_VDF)

Expand Down Expand Up @@ -721,7 +721,7 @@ async def test_invalid_icc_into_cc(self, empty_blockchain: Blockchain, bt: Block
),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss]
)

header_block_bad = get_block_header(block_bad)
Expand All @@ -743,7 +743,7 @@ async def test_invalid_icc_into_cc(self, empty_blockchain: Blockchain, bt: Block
block.finished_sub_slots[-1].reward_chain.replace(infused_challenge_chain_sub_slot_hash=None),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_bad_rc]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_bad_rc]
)
await _validate_and_add_block(blockchain, block_bad, expected_error=Err.INVALID_ICC_HASH_RC)
elif len(block.finished_sub_slots) > 0 and block.finished_sub_slots[-1].infused_challenge_chain is None:
Expand All @@ -757,7 +757,7 @@ async def test_invalid_icc_into_cc(self, empty_blockchain: Blockchain, bt: Block
),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_bad_cc]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_bad_cc]
)
await _validate_and_add_block(blockchain, block_bad, expected_error=Err.INVALID_ICC_HASH_CC)

Expand All @@ -771,7 +771,7 @@ async def test_invalid_icc_into_cc(self, empty_blockchain: Blockchain, bt: Block
),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_bad_rc]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_bad_rc]
)
await _validate_and_add_block(blockchain, block_bad, expected_error=Err.INVALID_ICC_HASH_RC)

Expand All @@ -792,7 +792,7 @@ async def test_empty_slot_no_ses(self, empty_blockchain: Blockchain, bt: BlockTo
blocks[-1].finished_sub_slots[-1].challenge_chain.replace(subepoch_summary_hash=std_hash(b"0")),
)
block_bad = recursive_replace(
blocks[-1], "finished_sub_slots", blocks[-1].finished_sub_slots[:-1] + [new_finished_ss]
blocks[-1], "finished_sub_slots", [*blocks[-1].finished_sub_slots[:-1], new_finished_ss]
)

header_block_bad = get_block_header(block_bad)
Expand Down Expand Up @@ -841,7 +841,7 @@ async def test_wrong_cc_hash_rc(self, empty_blockchain: Blockchain, bt: BlockToo
blocks[-1].finished_sub_slots[-1].reward_chain.replace(challenge_chain_sub_slot_hash=bytes32([3] * 32)),
)
block_1_bad = recursive_replace(
blocks[-1], "finished_sub_slots", blocks[-1].finished_sub_slots[:-1] + [new_finished_ss]
blocks[-1], "finished_sub_slots", [*blocks[-1].finished_sub_slots[:-1], new_finished_ss]
)

await _validate_and_add_block(blockchain, block_1_bad, expected_error=Err.INVALID_CHALLENGE_SLOT_HASH_RC)
Expand Down Expand Up @@ -879,7 +879,7 @@ async def test_invalid_cc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
)
log.warning(f"Num slots: {len(block.finished_sub_slots)}")
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss]
)
log.warning(f"Signage point index: {block_bad.reward_chain_block.signage_point_index}")
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_CC_EOS_VDF)
Expand All @@ -901,7 +901,7 @@ async def test_invalid_cc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
new_finished_ss_2.challenge_chain.get_hash(),
)
block_bad_2 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_2]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_2]
)
await _validate_and_add_block(empty_blockchain, block_bad_2, expected_error=Err.INVALID_CC_EOS_VDF)

Expand All @@ -922,7 +922,7 @@ async def test_invalid_cc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
new_finished_ss_3.challenge_chain.get_hash(),
)
block_bad_3 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_3]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_3]
)

await _validate_and_add_block_multi_error(
Expand All @@ -938,7 +938,7 @@ async def test_invalid_cc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
VDFProof(uint8(0), b"1239819023890", False),
)
block_bad_5 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_5]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_5]
)
await _validate_and_add_block(empty_blockchain, block_bad_5, expected_error=Err.INVALID_CC_EOS_VDF)

Expand Down Expand Up @@ -970,7 +970,7 @@ async def test_invalid_rc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
),
)
block_bad = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss]
)
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_RC_EOS_VDF)

Expand All @@ -985,7 +985,7 @@ async def test_invalid_rc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
),
)
block_bad_2 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_2]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_2]
)
await _validate_and_add_block(empty_blockchain, block_bad_2, expected_error=Err.INVALID_RC_EOS_VDF)

Expand All @@ -1000,7 +1000,7 @@ async def test_invalid_rc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
),
)
block_bad_3 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_3]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_3]
)
await _validate_and_add_block(empty_blockchain, block_bad_3, expected_error=Err.INVALID_RC_EOS_VDF)

Expand All @@ -1011,7 +1011,7 @@ async def test_invalid_rc_sub_slot_vdf(self, empty_blockchain: Blockchain, bt: B
VDFProof(uint8(0), b"1239819023890", False),
)
block_bad_5 = recursive_replace(
block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss_5]
block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss_5]
)
await _validate_and_add_block(empty_blockchain, block_bad_5, expected_error=Err.INVALID_RC_EOS_VDF)

Expand All @@ -1030,7 +1030,7 @@ async def test_genesis_bad_deficit(self, empty_blockchain: Blockchain, bt: Block
bt.constants.MIN_BLOCKS_PER_CHALLENGE_BLOCK - 1,
),
)
block_bad = recursive_replace(block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss])
block_bad = recursive_replace(block, "finished_sub_slots", [*block.finished_sub_slots[:-1], new_finished_ss])
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_DEFICIT)

@pytest.mark.anyio
Expand Down Expand Up @@ -1059,7 +1059,7 @@ async def test_reset_deficit(self, empty_blockchain: Blockchain, bt: BlockTools)
case_2 = True

block_bad = recursive_replace(
blocks[-1], "finished_sub_slots", blocks[-1].finished_sub_slots[:-1] + [new_finished_ss]
blocks[-1], "finished_sub_slots", [*blocks[-1].finished_sub_slots[:-1], new_finished_ss]
)
await _validate_and_add_block_multi_error(
empty_blockchain, block_bad, [Err.INVALID_DEFICIT, Err.INVALID_ICC_HASH_CC]
Expand Down Expand Up @@ -1088,7 +1088,7 @@ async def test_genesis_has_ses(self, empty_blockchain: Blockchain, bt: BlockTool
challenge_chain_sub_slot_hash=new_finished_ss.challenge_chain.get_hash()
),
)
block_bad = recursive_replace(block, "finished_sub_slots", [new_finished_ss] + block.finished_sub_slots[1:])
block_bad = recursive_replace(block, "finished_sub_slots", [new_finished_ss, *block.finished_sub_slots[1:]])
with pytest.raises(AssertionError):
# Fails pre validation
await _validate_and_add_block(
Expand Down Expand Up @@ -1124,7 +1124,7 @@ async def test_no_ses_if_no_se(self, empty_blockchain: Blockchain, bt: BlockTool
),
)
block_bad = recursive_replace(
blocks[-1], "finished_sub_slots", [new_finished_ss] + blocks[-1].finished_sub_slots[1:]
blocks[-1], "finished_sub_slots", [new_finished_ss, *blocks[-1].finished_sub_slots[1:]]
)
await _validate_and_add_block_multi_error(
empty_blockchain,
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2864,7 +2864,7 @@ async def test_invalid_coin_spend_coin(
c = cs.coin
coin_0 = Coin(c.parent_coin_info, bytes32([1] * 32), c.amount)
coin_spend_0 = make_spend(coin_0, cs.puzzle_reveal, cs.solution)
new_bundle = recursive_replace(spend_bundle, "coin_spends", [coin_spend_0] + spend_bundle.coin_spends[1:])
new_bundle = recursive_replace(spend_bundle, "coin_spends", [coin_spend_0, *spend_bundle.coin_spends[1:]])
assert spend_bundle is not None
res = await full_node_1.full_node.add_transaction(new_bundle, new_bundle.name(), test=True)
assert res == (MempoolInclusionStatus.FAILED, Err.INVALID_SPEND_BUNDLE)
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/util/test_streamable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
import re
from dataclasses import dataclass, field, fields
from typing import Any, Callable, Optional, get_type_hints
from typing import Any, Callable, ClassVar, Optional, get_type_hints

import pytest
from chia_rs import G1Element, SubEpochChallengeSegment
Expand Down Expand Up @@ -372,7 +372,7 @@ class PostInitTestClassBasic(Streamable):
@dataclass(frozen=True)
class PostInitTestClassBad(Streamable):
a: uint8
b = 0
b: ClassVar[uint8] = uint8(0)


@streamable
Expand Down
4 changes: 2 additions & 2 deletions chia/full_node/coin_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sqlite3
import time
from collections.abc import Collection
from typing import Any, Optional
from typing import Any, ClassVar, Optional

import typing_extensions
from aiosqlite import Cursor
Expand Down Expand Up @@ -406,7 +406,7 @@ async def get_coin_states_by_ids(

return coins

MAX_PUZZLE_HASH_BATCH_SIZE = SQLITE_MAX_VARIABLE_NUMBER - 10
MAX_PUZZLE_HASH_BATCH_SIZE: ClassVar[int] = SQLITE_MAX_VARIABLE_NUMBER - 10

async def batch_coin_states_by_puzzle_hashes(
self,
Expand Down
8 changes: 4 additions & 4 deletions chia/pools/pool_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class PoolWallet:

_protocol_check: ClassVar[WalletProtocol[object]] = cast("PoolWallet", None)

MINIMUM_INITIAL_BALANCE = 1
MINIMUM_RELATIVE_LOCK_HEIGHT = 5
MAXIMUM_RELATIVE_LOCK_HEIGHT = 1000
DEFAULT_MAX_CLAIM_SPENDS = 100
MINIMUM_INITIAL_BALANCE: ClassVar[int] = 1
MINIMUM_RELATIVE_LOCK_HEIGHT: ClassVar[int] = 5
MAXIMUM_RELATIVE_LOCK_HEIGHT: ClassVar[int] = 1000
DEFAULT_MAX_CLAIM_SPENDS: ClassVar[int] = 100

wallet_state_manager: WalletStateManager
log: logging.Logger
Expand Down
2 changes: 1 addition & 1 deletion chia/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ChiaServer:
connection_close_task: Optional[asyncio.Task[None]] = None
received_message_callback: Optional[ConnectionCallback] = None
banned_peers: dict[str, float] = field(default_factory=dict)
invalid_protocol_ban_seconds = INVALID_PROTOCOL_BAN_SECONDS
invalid_protocol_ban_seconds: int = INVALID_PROTOCOL_BAN_SECONDS

@classmethod
def create(
Expand Down
2 changes: 1 addition & 1 deletion chia/util/virtual_project_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def dfs(current: str, target: str, path: list[str]) -> None:
if current in visited:
return
if current == target and len(path) > 0:
all_paths.append(path[1:] + [current])
all_paths.append([*path[1:], current])
return
visited.add(current)
for provider in sorted(dependency_graph.get(current, [])):
Expand Down
Loading
Loading