From b409a2ff80c50080b70924c2322b78a87073dd1a Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 17 Oct 2025 10:31:03 -0700 Subject: [PATCH] Remove pyupgrade ignores --- cats/cats.py | 18 +++++++++--------- cats/secure_the_bag.py | 12 ++++++------ cats/unwind_the_bag.py | 4 ++-- ruff.toml | 5 ----- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/cats/cats.py b/cats/cats.py index 63cf606..bba85cd 100644 --- a/cats/cats.py +++ b/cats/cats.py @@ -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 @@ -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 @@ -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, @@ -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, @@ -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 @@ -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], @@ -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) @@ -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], @@ -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] diff --git a/cats/secure_the_bag.py b/cats/secure_the_bag.py index 44fd5d0..f450e11 100644 --- a/cats/secure_the_bag.py +++ b/cats/secure_the_bag.py @@ -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 @@ -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 @@ -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]]: """ @@ -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 @@ -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. """ diff --git a/cats/unwind_the_bag.py b/cats/unwind_the_bag.py index cb5a51d..bfa603d 100644 --- a/cats/unwind_the_bag.py +++ b/cats/unwind_the_bag.py @@ -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 @@ -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, diff --git a/ruff.toml b/ruff.toml index f3646dc..629d47a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -65,11 +65,6 @@ ignore = [ "RUF009", # function-call-in-dataclass-default-argument # Should probably fix this "RUF029", - - # TODO: Remove these - "UP045", - "UP007", - "UP035" ]