Skip to content

Commit c49ae98

Browse files
committed
typing fixes
1 parent 9f514ab commit c49ae98

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

chia/_tests/clvm/coin_store.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections import defaultdict
44
from collections.abc import Iterator
5-
from dataclasses import dataclass, replace
5+
from dataclasses import dataclass
66
from typing import Optional
77

88
from chia_rs import ConsensusConstants, SpendBundle, check_time_locks
@@ -113,8 +113,13 @@ def update_coin_store_for_spend_bundle(
113113
self._add_coin_entry(new_coin, now)
114114
for spent_coin in removals:
115115
coin_name = spent_coin.name()
116-
coin_record = self._db[coin_name]
117-
self._db[coin_name] = replace(coin_record, spent_block_index=now.height)
116+
self._db[coin_name] = CoinRecord(
117+
self._db[coin_name].coin,
118+
self._db[coin_name].confirmed_block_index,
119+
now.height,
120+
self._db[coin_name].coinbase,
121+
self._db[coin_name].timestamp,
122+
)
118123
return additions, spend_bundle.coin_spends
119124

120125
def coins_for_puzzle_hash(self, puzzle_hash: bytes32) -> Iterator[Coin]:

chia/_tests/core/mempool/test_mempool_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def test_conditions(
431431
conds: SpendBundleConditions,
432432
expected: Optional[Err],
433433
) -> None:
434-
res = check_time_locks(
434+
res: Optional[Union[int, Err]] = check_time_locks(
435435
dict(self.REMOVALS),
436436
conds,
437437
self.PREV_BLOCK_HEIGHT,
@@ -2340,7 +2340,13 @@ def __init__(self, coins: list[Coin], lineage: dict[bytes32, Coin]) -> None:
23402340
self.lineage_info[ph] = UnspentLineageInfo(c.name(), c.parent_coin_info, bytes32([42] * 32))
23412341

23422342
def spend_coin(self, coin_id: bytes32, height: uint32 = uint32(10)) -> None:
2343-
self.coin_records[coin_id] = dataclasses.replace(self.coin_records[coin_id], spent_block_index=height)
2343+
self.coin_records[coin_id] = CoinRecord(
2344+
self.coin_records[coin_id].coin,
2345+
self.coin_records[coin_id].confirmed_block_index,
2346+
height,
2347+
self.coin_records[coin_id].coinbase,
2348+
self.coin_records[coin_id].timestamp,
2349+
)
23442350

23452351
def update_lineage(self, puzzle_hash: bytes32, coin: Optional[Coin]) -> None:
23462352
if coin is None:

chia/full_node/mempool_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Awaitable, Collection
77
from concurrent.futures import Executor, ThreadPoolExecutor
88
from dataclasses import dataclass, field
9-
from typing import Callable, Optional, TypeVar
9+
from typing import Callable, Optional, TypeVar, Union
1010

1111
from chia_rs import (
1212
ELIGIBLE_FOR_DEDUP,
@@ -734,7 +734,7 @@ async def validate_spend_bundle(
734734
# point-of-view of the next block to be farmed. Therefore we pass in the
735735
# current peak's height and timestamp
736736
assert self.peak.timestamp is not None
737-
tl_error: Optional[Err] = check_time_locks(
737+
tl_error: Optional[Union[int, Err]] = check_time_locks(
738738
removal_record_dict,
739739
conds,
740740
self.peak.height,

0 commit comments

Comments
 (0)