Skip to content

Commit

Permalink
enable flake8-tidy-imports (#18913)
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky authored Nov 21, 2024
1 parent e17e657 commit d1596d4
Show file tree
Hide file tree
Showing 24 changed files with 123 additions and 131 deletions.
5 changes: 2 additions & 3 deletions chia/_tests/clvm/test_puzzles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from chia_rs import AugSchemeMPL, G1Element

from chia._tests.clvm.coin_store import CoinStore, CoinTimestamp
from chia._tests.core.make_block_generator import int_to_public_key
from chia._tests.util.key_tool import KeyTool
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.types.blockchain_format.program import Program
Expand All @@ -22,9 +24,6 @@
)
from chia.wallet.puzzles.puzzle_utils import make_create_coin_condition

from ..core.make_block_generator import int_to_public_key
from .coin_store import CoinStore, CoinTimestamp

T1 = CoinTimestamp(1, uint32(10000000))
T2 = CoinTimestamp(5, uint32(10003000))

Expand Down
5 changes: 2 additions & 3 deletions chia/_tests/core/full_node/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from clvm.casts import int_to_bytes
from clvm_tools.binutils import assemble

from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
from chia._tests.conftest import ConsensusMode
from chia._tests.core.full_node.ram_db import create_ram_blockchain
from chia.simulator.block_tools import BlockTools
from chia.simulator.keyring import TempKeyring
from chia.types.blockchain_format.program import Program
Expand All @@ -28,9 +30,6 @@
from chia.util.ints import uint32, uint64
from chia.wallet.conditions import AssertCoinAnnouncement, AssertPuzzleAnnouncement

from ...blockchain.blockchain_test_utils import _validate_and_add_block
from .ram_db import create_ram_blockchain


def cleanup_keyring(keyring: TempKeyring) -> None:
keyring.cleanup()
Expand Down
3 changes: 1 addition & 2 deletions chia/_tests/core/test_cost_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from chia_rs import G1Element
from clvm_tools import binutils

from chia._tests.core.make_block_generator import make_block_generator
from chia._tests.util.get_name_puzzle_conditions import get_name_puzzle_conditions
from chia._tests.util.misc import BenchmarkRunner
from chia.consensus.condition_costs import ConditionCost
Expand All @@ -23,8 +24,6 @@
from chia.util.ints import uint32, uint64
from chia.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle

from .make_block_generator import make_block_generator

BURN_PUZZLE_HASH = bytes32(b"0" * 32)
SMALL_BLOCK_GENERATOR = make_block_generator(1)

Expand Down
6 changes: 3 additions & 3 deletions chia/cmds/coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def list_cmd(
amounts_to_exclude: Sequence[CliAmount],
paginate: Optional[bool],
) -> None:
from .coin_funcs import async_list
from chia.cmds.coin_funcs import async_list

asyncio.run(
async_list(
Expand Down Expand Up @@ -129,7 +129,7 @@ def combine_cmd(
condition_valid_times: ConditionValidTimes,
override: bool,
) -> list[TransactionRecord]:
from .coin_funcs import async_combine
from chia.cmds.coin_funcs import async_combine

return asyncio.run(
async_combine(
Expand Down Expand Up @@ -199,7 +199,7 @@ def split_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .coin_funcs import async_split
from chia.cmds.coin_funcs import async_split

return asyncio.run(
async_split(
Expand Down
32 changes: 16 additions & 16 deletions chia/cmds/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def dao_add_cmd(
filter_amount: uint64,
name: Optional[str],
) -> None:
from .dao_funcs import add_dao_wallet
from chia.cmds.dao_funcs import add_dao_wallet

asyncio.run(add_dao_wallet(wallet_rpc_port, fingerprint, name, treasury_id, filter_amount))

Expand Down Expand Up @@ -171,7 +171,7 @@ def dao_create_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import create_dao_wallet
from chia.cmds.dao_funcs import create_dao_wallet

if self_destruct == proposal_timelock:
raise ValueError("Self Destruct and Proposal Timelock cannot be the same value")
Expand Down Expand Up @@ -226,7 +226,7 @@ def dao_get_id_cmd(
fingerprint: int,
wallet_id: int,
) -> None:
from .dao_funcs import get_treasury_id
from chia.cmds.dao_funcs import get_treasury_id

asyncio.run(get_treasury_id(wallet_rpc_port, fingerprint, wallet_id))

Expand Down Expand Up @@ -273,7 +273,7 @@ def dao_add_funds_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import add_funds_to_treasury
from chia.cmds.dao_funcs import add_funds_to_treasury

return asyncio.run(
add_funds_to_treasury(
Expand Down Expand Up @@ -311,7 +311,7 @@ def dao_get_balance_cmd(
fingerprint: int,
wallet_id: int,
) -> None:
from .dao_funcs import get_treasury_balance
from chia.cmds.dao_funcs import get_treasury_balance

asyncio.run(get_treasury_balance(wallet_rpc_port, fingerprint, wallet_id))

Expand All @@ -331,7 +331,7 @@ def dao_rules_cmd(
fingerprint: int,
wallet_id: int,
) -> None:
from .dao_funcs import get_rules
from chia.cmds.dao_funcs import get_rules

asyncio.run(get_rules(wallet_rpc_port, fingerprint, wallet_id))

Expand Down Expand Up @@ -362,7 +362,7 @@ def dao_list_proposals_cmd(
wallet_id: int,
include_closed: Optional[bool],
) -> None:
from .dao_funcs import list_proposals
from chia.cmds.dao_funcs import list_proposals

if not include_closed:
include_closed = False
Expand Down Expand Up @@ -393,7 +393,7 @@ def dao_show_proposal_cmd(
wallet_id: int,
proposal_id: str,
) -> None:
from .dao_funcs import show_proposal
from chia.cmds.dao_funcs import show_proposal

asyncio.run(show_proposal(wallet_rpc_port, fingerprint, wallet_id, proposal_id))

Expand Down Expand Up @@ -451,7 +451,7 @@ def dao_vote_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import vote_on_proposal
from chia.cmds.dao_funcs import vote_on_proposal

is_yes_vote = False if vote_no else True

Expand Down Expand Up @@ -523,7 +523,7 @@ def dao_close_proposal_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import close_proposal
from chia.cmds.dao_funcs import close_proposal

return asyncio.run(
close_proposal(
Expand Down Expand Up @@ -584,7 +584,7 @@ def dao_lockup_coins_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import lockup_coins
from chia.cmds.dao_funcs import lockup_coins

return asyncio.run(
lockup_coins(
Expand Down Expand Up @@ -632,7 +632,7 @@ def dao_release_coins_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import release_coins
from chia.cmds.dao_funcs import release_coins

return asyncio.run(
release_coins(
Expand Down Expand Up @@ -679,7 +679,7 @@ def dao_exit_lockup_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import exit_lockup
from chia.cmds.dao_funcs import exit_lockup

return asyncio.run(
exit_lockup(
Expand Down Expand Up @@ -780,7 +780,7 @@ def dao_create_spend_proposal_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import create_spend_proposal
from chia.cmds.dao_funcs import create_spend_proposal

return asyncio.run(
create_spend_proposal(
Expand Down Expand Up @@ -889,7 +889,7 @@ def dao_create_update_proposal_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import create_update_proposal
from chia.cmds.dao_funcs import create_update_proposal

return asyncio.run(
create_update_proposal(
Expand Down Expand Up @@ -969,7 +969,7 @@ def dao_create_mint_proposal_cmd(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
from .dao_funcs import create_mint_proposal
from chia.cmds.dao_funcs import create_mint_proposal

return asyncio.run(
create_mint_proposal(
Expand Down
4 changes: 2 additions & 2 deletions chia/cmds/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def summary_cmd(
) -> None:
import asyncio

from .farm_funcs import summary
from chia.cmds.farm_funcs import summary

asyncio.run(summary(rpc_port, wallet_rpc_port, harvester_rpc_port, farmer_rpc_port))

Expand All @@ -82,6 +82,6 @@ def summary_cmd(
def challenges_cmd(farmer_rpc_port: Optional[int], limit: int) -> None:
import asyncio

from .farm_funcs import challenges
from chia.cmds.farm_funcs import challenges

asyncio.run(challenges(farmer_rpc_port, limit))
6 changes: 2 additions & 4 deletions chia/cmds/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def init_cmd(
"""
from pathlib import Path

from chia.cmds.init_funcs import init
from chia.cmds.passphrase_funcs import initialize_passphrase

from .init_funcs import init

if set_passphrase:
initialize_passphrase()

Expand All @@ -63,8 +62,7 @@ def init_cmd(


if __name__ == "__main__":
from chia.cmds.init_funcs import chia_init
from chia.util.default_root import DEFAULT_ROOT_PATH

from .init_funcs import chia_init

chia_init(DEFAULT_ROOT_PATH)
34 changes: 17 additions & 17 deletions chia/cmds/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def keys_cmd(ctx: click.Context) -> None:
)
@click.pass_context
def generate_cmd(ctx: click.Context, label: Optional[str]) -> None:
from .init_funcs import check_keys
from .keys_funcs import generate_and_add
from chia.cmds.init_funcs import check_keys
from chia.cmds.keys_funcs import generate_and_add

generate_and_add(label)
check_keys(ctx.obj["root_path"])
Expand Down Expand Up @@ -75,7 +75,7 @@ def show_cmd(
fingerprint: Optional[int],
bech32m_prefix: Optional[str],
) -> None:
from .keys_funcs import show_keys
from chia.cmds.keys_funcs import show_keys

show_keys(ctx.obj["root_path"], show_mnemonic_seed, non_observer_derivation, json, fingerprint, bech32m_prefix)

Expand All @@ -99,8 +99,8 @@ def show_cmd(
)
@click.pass_context
def add_cmd(ctx: click.Context, filename: str, label: Optional[str]) -> None:
from .init_funcs import check_keys
from .keys_funcs import query_and_add_key_info
from chia.cmds.init_funcs import check_keys
from chia.cmds.keys_funcs import query_and_add_key_info

mnemonic_or_pk = None
if filename:
Expand All @@ -119,7 +119,7 @@ def label_cmd() -> None:

@label_cmd.command("show", help="Show the labels of all available keys")
def show_label_cmd() -> None:
from .keys_funcs import show_all_key_labels
from chia.cmds.keys_funcs import show_all_key_labels

show_all_key_labels()

Expand All @@ -134,15 +134,15 @@ def show_label_cmd() -> None:
required=True,
)
def set_label_cmd(fingerprint: int, label: str) -> None:
from .keys_funcs import set_key_label
from chia.cmds.keys_funcs import set_key_label

set_key_label(fingerprint, label)


@label_cmd.command("delete", help="Delete the label of a key")
@options.create_fingerprint(required=True)
def delete_label_cmd(fingerprint: int) -> None:
from .keys_funcs import delete_key_label
from chia.cmds.keys_funcs import delete_key_label

delete_key_label(fingerprint)

Expand All @@ -151,8 +151,8 @@ def delete_label_cmd(fingerprint: int) -> None:
@options.create_fingerprint(required=True)
@click.pass_context
def delete_cmd(ctx: click.Context, fingerprint: int) -> None:
from .init_funcs import check_keys
from .keys_funcs import delete
from chia.cmds.init_funcs import check_keys
from chia.cmds.keys_funcs import delete

delete(fingerprint)
check_keys(ctx.obj["root_path"])
Expand All @@ -167,7 +167,7 @@ def delete_all_cmd() -> None:

@keys_cmd.command("generate_and_print", help="Generates but does NOT add to keychain")
def generate_and_print_cmd() -> None:
from .keys_funcs import generate_and_print
from chia.cmds.keys_funcs import generate_and_print

generate_and_print()

Expand Down Expand Up @@ -203,7 +203,7 @@ def generate_and_print_cmd() -> None:
def sign_cmd(
message: str, fingerprint: Optional[int], filename: Optional[str], hd_path: str, as_bytes: bool, json: bool
) -> None:
from .keys_funcs import resolve_derivation_master_key, sign
from chia.cmds.keys_funcs import resolve_derivation_master_key, sign

_, resolved_sk = resolve_derivation_master_key(filename if filename is not None else fingerprint)

Expand Down Expand Up @@ -253,7 +253,7 @@ def parse_signature_json(json_str: str) -> tuple[str, str, str, str]:
type=str,
)
def verify_cmd(message: str, public_key: str, signature: str, as_bytes: bool, json: str) -> None:
from .keys_funcs import as_bytes_from_signing_mode, verify
from chia.cmds.keys_funcs import as_bytes_from_signing_mode, verify

if json is not None:
parsed_message, parsed_pubkey, parsed_sig, parsed_signing_mode_str = parse_signature_json(json)
Expand Down Expand Up @@ -330,7 +330,7 @@ def search_cmd(
) -> None:
import sys

from .keys_funcs import resolve_derivation_master_key, search_derive
from chia.cmds.keys_funcs import resolve_derivation_master_key, search_derive

fingerprint: Optional[int] = ctx.obj.get("fingerprint", None)
filename: Optional[str] = ctx.obj.get("filename", None)
Expand Down Expand Up @@ -365,7 +365,7 @@ class ResolutionError(Exception):
def _resolve_fingerprint_and_sk(
filename: Optional[str], fingerprint: Optional[int], non_observer_derivation: bool
) -> tuple[Optional[int], Optional[PrivateKey]]:
from .keys_funcs import resolve_derivation_master_key
from chia.cmds.keys_funcs import resolve_derivation_master_key

reolved_fp, resolved_sk = resolve_derivation_master_key(filename if filename is not None else fingerprint)

Expand Down Expand Up @@ -408,7 +408,7 @@ def _resolve_fingerprint_and_sk(
def wallet_address_cmd(
ctx: click.Context, index: int, count: int, prefix: Optional[str], non_observer_derivation: bool, show_hd_path: bool
) -> None:
from .keys_funcs import derive_wallet_address
from chia.cmds.keys_funcs import derive_wallet_address

fingerprint: Optional[int] = ctx.obj.get("fingerprint", None)
filename: Optional[str] = ctx.obj.get("filename", None)
Expand Down Expand Up @@ -483,7 +483,7 @@ def child_key_cmd(
show_hd_path: bool,
bech32m_prefix: Optional[str],
) -> None:
from .keys_funcs import derive_child_key
from chia.cmds.keys_funcs import derive_child_key

if key_type is None and derive_from_hd_path is None:
ctx.fail("--type or --derive-from-hd-path is required")
Expand Down
Loading

0 comments on commit d1596d4

Please sign in to comment.