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
18 changes: 9 additions & 9 deletions cats/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections.abc import AsyncIterator, Iterable
from contextlib import asynccontextmanager
from pathlib import Path
from typing import Any, Optional, Union
from typing import Any

import click
from chia.cmds.cmds_util import get_wallet_client
Expand Down Expand Up @@ -37,7 +37,7 @@
# Loading the client requires the standard chia root directory configuration that all of the chia commands rely on
@asynccontextmanager
async def get_context_manager(
wallet_rpc_port: Optional[int], fingerprint: int, root_path: Path
wallet_rpc_port: int | None, fingerprint: int, root_path: Path
) -> AsyncIterator[tuple[WalletRpcClient, int, dict[str, Any]]]:
config = load_config(root_path, "config.yaml")
wallet_rpc_port = config["wallet"]["rpc_port"] if wallet_rpc_port is None else wallet_rpc_port
Expand All @@ -46,7 +46,7 @@ async def get_context_manager(


async def get_signed_tx(
wallet_rpc_port: Optional[int],
wallet_rpc_port: int | None,
fingerprint: int,
ph: bytes32,
amt: uint64,
Expand All @@ -66,7 +66,7 @@ async def get_signed_tx(


async def push_tx(
wallet_rpc_port: Optional[int],
wallet_rpc_port: int | None,
fingerprint: int,
bundle: WalletSpendBundle,
root_path: Path,
Expand All @@ -88,7 +88,7 @@ def append_include(search_paths: Iterable[str]) -> list[str]:
return ["./include"]


def parse_program(program: Union[str, Program], include: Iterable[str] = []) -> Program:
def parse_program(program: str | Program, include: Iterable[str] = []) -> Program:
prog: Program
if isinstance(program, Program):
return program
Expand Down Expand Up @@ -255,7 +255,7 @@ def cli(
amount: int,
fee: int,
authorized_provider: list[str],
proofs_checker: Optional[str],
proofs_checker: str | None,
cr_flag: list[str],
fingerprint: int,
signature: list[str],
Expand All @@ -265,7 +265,7 @@ def cli(
quiet: bool,
push: bool,
root_path: str,
wallet_rpc_port: Optional[int],
wallet_rpc_port: int | None,
) -> None:
ctx.ensure_object(dict)

Expand Down Expand Up @@ -301,7 +301,7 @@ async def cmd_func(
amount: int,
fee: int,
authorized_provider: list[str],
proofs_checker: Optional[str],
proofs_checker: str | None,
cr_flag: list[str],
fingerprint: int,
signature: list[str],
Expand All @@ -311,7 +311,7 @@ async def cmd_func(
quiet: bool,
push: bool,
root_path: str,
wallet_rpc_port: Optional[int],
wallet_rpc_port: int | None,
) -> None:
parsed_tail: Program = parse_program(tail)
curried_args = [assemble(arg) for arg in curry]
Expand Down
12 changes: 6 additions & 6 deletions cats/secure_the_bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import csv
import re
from collections.abc import Iterable
from typing import Any, Union
from typing import Any

import click
from chia.types.blockchain_format.coin import Coin
Expand Down Expand Up @@ -34,7 +34,7 @@ def append_include(search_paths: Iterable[str]) -> list[str]:
return ["./include"]


def parse_program(program: Union[str, Program], include: Iterable[str] = []) -> Program:
def parse_program(program: str | Program, include: Iterable[str] = []) -> Program:
prog: Program
if isinstance(program, Program):
return program
Expand Down Expand Up @@ -109,7 +109,7 @@ def batch_the_bag(targets: list[Target], leaf_width: int) -> list[list[Target]]:
def secure_the_bag(
targets: list[Target],
leaf_width: int,
asset_id: Union[bytes32, None] = None,
asset_id: bytes32 | None = None,
parent_puzzle_lookup: dict[str, TargetCoin] = {},
) -> tuple[bytes32, dict[str, TargetCoin]]:
"""
Expand Down Expand Up @@ -169,8 +169,8 @@ def parent_of_puzzle_hash(
genesis_coin_name: bytes32,
puzzle_hash: bytes32,
parent_puzzle_lookup: dict[str, TargetCoin],
) -> tuple[Union[CoinSpend, None], bytes32]:
parent: Union[TargetCoin, None] = parent_puzzle_lookup.get(puzzle_hash.hex())
) -> tuple[CoinSpend | None, bytes32]:
parent: TargetCoin | None = parent_puzzle_lookup.get(puzzle_hash.hex())

if parent is None:
return None, genesis_coin_name
Expand All @@ -183,7 +183,7 @@ def parent_of_puzzle_hash(
return make_spend(coin, parent.puzzle, Program.to([])), coin.name()


def read_secure_the_bag_targets(secure_the_bag_targets_path: str, target_amount: Union[int, None]) -> list[Target]:
def read_secure_the_bag_targets(secure_the_bag_targets_path: str, target_amount: int | None) -> list[Target]:
"""
Reads secure the bag targets file. Validates the net amount sent to targets is equal to the target amount.
"""
Expand Down
4 changes: 2 additions & 2 deletions cats/unwind_the_bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import defaultdict
from collections.abc import Coroutine
from pathlib import Path
from typing import Any, Optional
from typing import Any

import click
from chia.cmds.cmds_util import get_wallet
Expand Down Expand Up @@ -228,7 +228,7 @@ async def app(
secure_the_bag_targets_path: str,
leaf_width: int,
tail_hash_bytes: bytes32,
unwind_target_puzzle_hash_bytes: Optional[bytes32],
unwind_target_puzzle_hash_bytes: bytes32 | None,
genesis_coin_id: bytes32,
fingerprint: int,
wallet_id: int,
Expand Down
5 changes: 0 additions & 5 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ ignore = [
"RUF009", # function-call-in-dataclass-default-argument
# Should probably fix this
"RUF029",

# TODO: Remove these
"UP045",
"UP007",
"UP035"
]


Expand Down