diff --git a/benchmarks/streamable.py b/benchmarks/streamable.py index d7d8a4a8f02b..a6018b8d4fdf 100644 --- a/benchmarks/streamable.py +++ b/benchmarks/streamable.py @@ -14,7 +14,7 @@ from chia_rs.sized_bytes import bytes32 from chia_rs.sized_ints import uint8, uint64 -from benchmarks.utils import EnumType, get_commit_hash +from benchmarks.utils import get_commit_hash from chia._tests.util.benchmarks import rand_full_block, rand_hash from chia.util.streamable import Streamable, streamable @@ -226,8 +226,8 @@ def compare_results( @click.command() -@click.option("-d", "--data", default=Data.all, type=EnumType(Data)) -@click.option("-m", "--mode", default=Mode.all, type=EnumType(Mode)) +@click.option("-d", "--data", default=Data.all, type=click.Choice(Data)) +@click.option("-m", "--mode", default=Mode.all, type=click.Choice(Mode)) @click.option("-r", "--runs", default=100, help="Number of benchmark runs to average results") @click.option("-t", "--ms", default=50, help="Milliseconds per run") @click.option("--live/--no-live", default=False, help="Print live results (slower)") diff --git a/benchmarks/utils.py b/benchmarks/utils.py index 97b1b2066083..1f8c756d22f5 100644 --- a/benchmarks/utils.py +++ b/benchmarks/utils.py @@ -1,31 +1,15 @@ from __future__ import annotations import contextlib -import enum import os import subprocess import sys from collections.abc import AsyncIterator from pathlib import Path -from typing import Any, Generic, Optional, TypeVar, Union - -import click +from typing import Optional, Union from chia.util.db_wrapper import DBWrapper2 -_T_Enum = TypeVar("_T_Enum", bound=enum.Enum) - - -# Workaround to allow `Enum` with click.Choice: https://github.com/pallets/click/issues/605#issuecomment-901099036 -class EnumType(click.Choice, Generic[_T_Enum]): - def __init__(self, enum: type[_T_Enum], case_sensitive: bool = False) -> None: - self.__enum = enum - super().__init__(choices=[item.value for item in enum], case_sensitive=case_sensitive) - - def convert(self, value: Any, param: Optional[click.Parameter], ctx: Optional[click.Context]) -> _T_Enum: - converted_str = super().convert(value, param, ctx) - return self.__enum(converted_str) - @contextlib.asynccontextmanager async def setup_db(name: Union[str, os.PathLike[str]], db_version: int) -> AsyncIterator[DBWrapper2]: diff --git a/chia/_tests/wallet/test_signer_protocol.py b/chia/_tests/wallet/test_signer_protocol.py index c1d7a0dc590e..5817478613bc 100644 --- a/chia/_tests/wallet/test_signer_protocol.py +++ b/chia/_tests/wallet/test_signer_protocol.py @@ -687,6 +687,7 @@ async def test_signer_commands(wallet_environments: WalletTestFramework) -> None ) +@pytest.mark.filterwarnings("ignore:The parameter .* is used more than once:UserWarning") def test_signer_command_default_parsing() -> None: check_click_parsing( GatherSigningInfoCMD( diff --git a/chia/cmds/wallet.py b/chia/cmds/wallet.py index c91158d84922..5a5fd402e439 100644 --- a/chia/cmds/wallet.py +++ b/chia/cmds/wallet.py @@ -94,7 +94,7 @@ def get_transaction_cmd( "--limit", help="Max number of transactions to return", type=int, - default=(2**32 - 1), + default=(2**16 - 1), show_default=True, required=False, ) @@ -105,19 +105,19 @@ def get_transaction_cmd( help="Prompt for each page of data. Defaults to true for interactive consoles, otherwise false.", ) @click.option( - "--sort-by-height", + "--sort-by-relevance", "sort_key", - flag_value=SortKey.CONFIRMED_AT_HEIGHT, + flag_value=SortKey.RELEVANCE, type=SortKey, - help="Sort transactions by height", + default=SortKey.RELEVANCE, + help="Sort transactions by {confirmed, height, time}", ) @click.option( - "--sort-by-relevance", + "--sort-by-height", "sort_key", - flag_value=SortKey.RELEVANCE, + flag_value=SortKey.CONFIRMED_AT_HEIGHT, type=SortKey, - default=True, - help="Sort transactions by {confirmed, height, time}", + help="Sort transactions by height", ) @click.option( "--reverse", diff --git a/poetry.lock b/poetry.lock index 663af759b2f8..238d93b64dc3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1018,14 +1018,14 @@ files = [ [[package]] name = "click" -version = "8.1.8" +version = "8.3.0" description = "Composable command line interface toolkit" optional = false -python-versions = ">=3.7" +python-versions = ">=3.10" groups = ["main"] files = [ - {file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, - {file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, + {file = "click-8.3.0-py3-none-any.whl", hash = "sha256:9b9f285302c6e3064f4330c05f05b81945b2a39544279343e6e7c5f27a9baddc"}, + {file = "click-8.3.0.tar.gz", hash = "sha256:e7b8232224eba16f4ebe410c25ced9f7875cb5f3263ffc93cc3e8da705e229c4"}, ] [package.dependencies]