Skip to content
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

build(deps-dev): bump pylint from 3.1.0 to 3.2.2 #18019

Merged
merged 8 commits into from
Jun 3, 2024
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
2 changes: 2 additions & 0 deletions chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ async def test_kv_diff(data_store: DataStore, store_id: bytes32) -> None:
random.seed(100, version=2)
insertions = 0
expected_diff: Set[DiffData] = set()
root_start = None
for i in range(500):
key = (i + 100).to_bytes(4, byteorder="big")
value = (i + 200).to_bytes(4, byteorder="big")
Expand Down Expand Up @@ -1158,6 +1159,7 @@ async def test_kv_diff(data_store: DataStore, store_id: bytes32) -> None:
root_start = await data_store.get_tree_root(store_id)

root_end = await data_store.get_tree_root(store_id)
assert root_start is not None
assert root_start.node_hash is not None
assert root_end.node_hash is not None
diffs = await data_store.get_kv_diff(store_id, root_start.node_hash, root_end.node_hash)
Expand Down
3 changes: 3 additions & 0 deletions chia/_tests/wallet/cat_wallet/test_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import tempfile
from pathlib import Path
from typing import Optional

import pytest

Expand Down Expand Up @@ -459,9 +460,11 @@ async def test_cat_reuse_address(self_hostname: str, two_wallet_nodes: OldSimula
assert tx_record.to_puzzle_hash == cat_2_hash
assert tx_record.spend_bundle is not None
assert len(tx_record.spend_bundle.coin_spends) == 2
old_puzhash: Optional[str] = None
for cs in tx_record.spend_bundle.coin_spends:
if cs.coin.amount == 100:
old_puzhash = cs.coin.puzzle_hash.hex()
assert old_puzhash is not None
new_puzhash = [c.puzzle_hash.hex() for c in tx_record.additions]
assert old_puzhash in new_puzhash

Expand Down
5 changes: 4 additions & 1 deletion chia/_tests/wallet/nft_wallet/test_nft_puzzles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import random
from typing import Tuple
from typing import Optional, Tuple

from chia._tests.core.make_block_generator import int_to_public_key
from chia.types.blockchain_format.program import Program
Expand Down Expand Up @@ -85,11 +85,14 @@ def test_nft_transfer_puzzle_hashes(seeded_random: random.Random) -> None:

conds = nft_puz.run(nft_sol)

expected_ph: Optional[bytes32] = None
# get the new NFT puzhash
for cond in conds.as_iter():
if cond.first().as_int() == 51:
expected_ph = bytes32(cond.at("rf").as_atom())

assert expected_ph is not None

# recreate the puzzle for new_puzhash
new_ownership_puz = NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER.get_tree_hash(), None, transfer_puz, taker_p2_puz)
new_metadata_puz = NFT_STATE_LAYER_MOD.curry(
Expand Down
10 changes: 9 additions & 1 deletion chia/_tests/wallet/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
import tempfile
from pathlib import Path
from typing import Any
from typing import Any, Optional

import pytest

Expand Down Expand Up @@ -106,6 +106,9 @@ async def track_coin_state(*args: Any) -> bool:

notification_manager_2.potentially_add_new_notification = track_coin_state

allow_larger_height: Optional[int] = None
allow_height: Optional[int] = None

for case in ("block all", "block too low", "allow", "allow_larger", "block_too_large"):
msg: bytes = bytes(case, "utf8")
if case == "block all":
Expand All @@ -128,6 +131,8 @@ async def track_coin_state(*args: Any) -> bool:
msg = bytes([0] * 10001)
AMOUNT = uint64(750000000000)
FEE = uint64(0)
else:
raise Exception(f"Unhandled case: {case!r}")
peak = full_node_api.full_node.blockchain.get_peak()
assert peak is not None
if case == "allow":
Expand All @@ -151,6 +156,9 @@ async def track_coin_state(*args: Any) -> bool:
await time_out_assert(30, wallet_2.get_unconfirmed_balance, funds_2)
await time_out_assert(30, wallet_2.get_confirmed_balance, funds_2)

assert allow_larger_height is not None
assert allow_height is not None

notifications = await notification_manager_2.notification_store.get_all_notifications(pagination=(0, 2))
assert len(notifications) == 2
assert notifications[0].message == b"allow_larger"
Expand Down
8 changes: 6 additions & 2 deletions chia/_tests/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dataclasses
from pathlib import Path
from typing import Any, Dict, List, Tuple
from typing import Any, Dict, List, Optional, Tuple

import pytest
from chia_rs import AugSchemeMPL, G1Element, G2Element
Expand All @@ -15,7 +15,7 @@
from chia.simulator.simulator_protocol import ReorgProtocol
from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.coin_spend import compute_additions
from chia.types.coin_spend import CoinSpend, compute_additions
from chia.types.peer_info import PeerInfo
from chia.types.signing_mode import CHIP_0002_SIGN_MESSAGE_PREFIX
from chia.types.spend_bundle import estimate_fees
Expand Down Expand Up @@ -1691,10 +1691,14 @@ async def test_wallet_prevent_fee_theft(self, wallet_environments: WalletTestFra
)
assert tx.spend_bundle is not None

stolen_cs: Optional[CoinSpend] = None
# extract coin_spend from generated spend_bundle
for cs in tx.spend_bundle.coin_spends:
if compute_additions(cs) == []:
stolen_cs = cs

assert stolen_cs is not None

# get a legit signature
stolen_sb, _ = await wallet.wallet_state_manager.sign_bundle([stolen_cs])
name = stolen_sb.name()
Expand Down
4 changes: 4 additions & 0 deletions chia/cmds/check_wallet_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,17 @@ async def check_wallets(self) -> List[str]:
except Exception as e:
errors.append(f"Exception while trying to access wallet {main_wallet_id} from users_wallets: {e}")

max_id: Optional[int] = None
max_id_row = await execute_fetchone(reader, "SELECT MAX(id) FROM users_wallets")
if max_id_row is None:
errors.append("Error fetching max wallet ID from table users_wallets. No wallets ?!?")
else:
cursor = await reader.execute("""SELECT * FROM users_wallets""")
rows = await cursor.fetchall()
max_id = max_id_row[0]

assert max_id is not None

errors.extend(check_for_gaps([r[0] for r in rows], main_wallet_id, max_id, data_type_plural="Wallet IDs"))

if self.verbose:
Expand Down
2 changes: 2 additions & 0 deletions chia/cmds/dao_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ async def show_proposal(args: Dict[str, Any], wallet_rpc_port: Optional[int], fp
ptype = "spend"
elif ptype_val == "u":
ptype = "update"
else:
raise Exception(f"Unknown proposal type: {ptype_val!r}")

print("")
print(f"Details of Proposal: {proposal_id}")
Expand Down
2 changes: 2 additions & 0 deletions chia/cmds/keys_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ def derive_child_key(
derivation_root_pk, derivation_root_sk, hd_path_root = derive_pk_and_sk_from_hd_path(
current_pk, derive_from_hd_path, master_sk=current_sk
)
else:
raise Exception("Neither key type nor HD path was specified")

# Derive child keys from derivation_root_sk
for i in range(index, index + count):
Expand Down
4 changes: 4 additions & 0 deletions chia/data_layer/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ async def _check_hashes(self) -> None:
expected_hash = internal_hash(left_hash=node.left_hash, right_hash=node.right_hash)
elif isinstance(node, TerminalNode):
expected_hash = Program.to((node.key, node.value)).get_tree_hash()
else:
raise Exception(f"Internal error, unknown node type: {node!r}")

if node.hash != expected_hash:
bad_node_hashes.append(node.hash)
Expand Down Expand Up @@ -1172,6 +1174,8 @@ async def insert(
elif side == Side.RIGHT:
left = reference_node_hash
right = new_terminal_node_hash
else:
raise Exception(f"Internal error, unknown side: {side!r}")

ancestors = await self.get_ancestors_common(
node_hash=reference_node_hash,
Expand Down
3 changes: 3 additions & 0 deletions chia/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ async def create_new_wallet(
uint64(request.get("filter_amount", 1)),
name,
)
else:
raise Exception(f"Invalid DAO wallet mode: {mode!r}")

return {
"success": True,
"type": dao_wallet.type(),
Expand Down
3 changes: 3 additions & 0 deletions chia/wallet/cat_wallet/cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ async def generate_unsigned_spendbundle(
primaries=primaries,
conditions=(*extra_conditions, xch_announcement, announcement),
)
else:
# TODO: what about when they are equal?
raise Exception("Equality not handled")
else:
innersol = self.standard_wallet.make_solution(
primaries=primaries,
Expand Down
5 changes: 5 additions & 0 deletions chia/wallet/dao_wallet/dao_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,9 @@ async def create_proposal_close_spend(
treasury_inner_puzhash = self.dao_info.current_treasury_innerpuz.get_tree_hash()
delegated_solution = Program.to([])

else:
raise Exception(f"Unknown proposal type: {proposal_type!r}")

treasury_solution = Program.to(
[
[proposal_info.current_coin.name(), PROPOSED_PUZ_HASH.as_atom(), 0],
Expand Down Expand Up @@ -1467,6 +1470,8 @@ async def create_proposal_close_spend(
if self_destruct:
spend_bundle = SpendBundle([proposal_cs, treasury_cs], AugSchemeMPL.aggregate([]))
else:
# TODO: maybe we can refactor this to provide clarity around timer_cs having been defined
# pylint: disable-next=E0606
spend_bundle = SpendBundle([proposal_cs, timer_cs, treasury_cs], AugSchemeMPL.aggregate([]))
if fee > 0:
chia_tx = await self.standard_wallet.create_tandem_xch_tx(fee, tx_config)
Expand Down
55 changes: 27 additions & 28 deletions chia/wallet/nft_wallet/nft_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,40 +1392,39 @@ async def mint_from_did(
# Create the xch spend to fund the minting.
spend_value = sum([coin.amount for coin in xch_coins])
change: uint64 = uint64(spend_value - total_amount)
xch_spends = []
if xch_change_ph is None:
xch_change_ph = await self.standard_wallet.get_new_puzzlehash()
xch_payment = Payment(xch_change_ph, change, [xch_change_ph])

first = True
for xch_coin in xch_coins:
puzzle: Program = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
if first:
message_list: List[bytes32] = [c.name() for c in xch_coins]
message_list.append(Coin(xch_coin.name(), xch_payment.puzzle_hash, xch_payment.amount).name())
message: bytes32 = std_hash(b"".join(message_list))
xch_coins_iter = iter(xch_coins)
xch_coin = next(xch_coins_iter)

xch_extra_conditions: Tuple[Condition, ...] = (
AssertCoinAnnouncement(asserted_id=did_coin.name(), asserted_msg=message),
)
if len(xch_coins) > 1:
xch_extra_conditions += (CreateCoinAnnouncement(message),)
message_list: List[bytes32] = [c.name() for c in xch_coins]
message_list.append(Coin(xch_coin.name(), xch_payment.puzzle_hash, xch_payment.amount).name())
message: bytes32 = std_hash(b"".join(message_list))

solution: Program = self.standard_wallet.make_solution(
primaries=[xch_payment],
fee=fee,
conditions=xch_extra_conditions,
)
primary_announcement_hash = AssertCoinAnnouncement(
asserted_id=xch_coin.name(), asserted_msg=message
).msg_calc
# connect this coin assertion to the DID announcement
did_coin_announcement = CreateCoinAnnouncement(message)
first = False
else:
solution = self.standard_wallet.make_solution(
primaries=[], conditions=(AssertCoinAnnouncement(primary_announcement_hash),)
)
xch_extra_conditions: Tuple[Condition, ...] = (
AssertCoinAnnouncement(asserted_id=did_coin.name(), asserted_msg=message),
)
if len(xch_coins) > 1:
xch_extra_conditions += (CreateCoinAnnouncement(message),)

solution: Program = self.standard_wallet.make_solution(
primaries=[xch_payment],
fee=fee,
conditions=xch_extra_conditions,
)
primary_announcement_hash = AssertCoinAnnouncement(asserted_id=xch_coin.name(), asserted_msg=message).msg_calc
# connect this coin assertion to the DID announcement
did_coin_announcement = CreateCoinAnnouncement(message)
puzzle = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
xch_spends = [make_spend(xch_coin, puzzle, solution)]

for xch_coin in xch_coins_iter:
puzzle = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
solution = self.standard_wallet.make_solution(
primaries=[], conditions=(AssertCoinAnnouncement(primary_announcement_hash),)
)
xch_spends.append(make_spend(xch_coin, puzzle, solution))
xch_spend = SpendBundle(xch_spends, G2Element())

Expand Down
7 changes: 5 additions & 2 deletions chia/wallet/util/debug_spend_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def debug_spend_bundle(spend_bundle, agg_sig_additional_data=DEFAULT_CONSTANTS.A
for c in condition_programs:
if len(c.vars) == 0:
as_prog = Program.to([c.opcode])
if len(c.vars) == 1:
elif len(c.vars) == 1:
as_prog = Program.to([c.opcode, c.vars[0]])
if len(c.vars) == 2:
elif len(c.vars) == 2:
if c.opcode == ConditionOpcode.CREATE_COIN:
cc = next(
cc
Expand All @@ -136,6 +136,9 @@ def debug_spend_bundle(spend_bundle, agg_sig_additional_data=DEFAULT_CONSTANTS.A
as_prog = Program.to([c.opcode, c.vars[0], c.vars[1]])
else:
as_prog = Program.to([c.opcode, c.vars[0], c.vars[1]])
else:
raise Exception(f"Unexpected number of vars: {len(c.vars)}")

print(f" {disassemble(as_prog)}")
created_coin_announcements.extend(
[coin_name] + _.vars for _ in conditions.get(ConditionOpcode.CREATE_COIN_ANNOUNCEMENT, [])
Expand Down
3 changes: 3 additions & 0 deletions chia/wallet/vc_wallet/cr_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ async def _generate_unsigned_spendbundle(
primaries=primaries,
conditions=(*extra_conditions, xch_announcement, announcement),
)
else:
# TODO: what about when they are equal?
raise Exception("Equality not handled")
else:
innersol = self.standard_wallet.make_solution(
primaries=primaries,
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ignore-patterns=
#init-hook=

# Use multiple processes to speed up Pylint.
jobs=1
jobs=4

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"pre-commit==3.5.0; python_version < '3.9'",
"pre-commit==3.7.1; python_version >= '3.9'",
"py3createtorrent==1.2.0",
"pylint==3.1.0",
"pylint==3.2.2",
"pytest==8.1.1",
"pytest-cov==5.0.0",
"pytest-mock==3.14.0",
Expand Down
Loading