diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 94e06dd..1de996d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,6 @@ repos: -- repo: local - hooks: - - id: isort - name: isort - entry: isort - require_serial: true - language: python - language_version: python3 - types_or: [cython, pyi, python] - args: ['--filter-files'] - minimum_pre_commit_version: '2.9.2' - additional_dependencies: [isort==5.13.2] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -21,14 +9,15 @@ repos: - id: check-merge-conflict - id: check-ast - id: debug-statements -- repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black -- repo: https://github.com/pycqa/flake8 - rev: 7.0.0 +- repo: local hooks: - - id: flake8 + - id: ruff_format + name: ruff format + entry: ruff format + language: system + require_serial: true + types_or: [python, pyi] + - repo: local hooks: - id: mypy @@ -36,3 +25,10 @@ repos: entry: mypy language: system pass_filenames: false +- repo: local + hooks: + - id: ruff + name: Ruff + entry: ruff check --fix + language: system + types: [python] diff --git a/chianft/__init__.py b/chianft/__init__.py index 9f775f4..f981a44 100644 --- a/chianft/__init__.py +++ b/chianft/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pkg_resources import DistributionNotFound, get_distribution try: diff --git a/chianft/cmds/cli.py b/chianft/cmds/cli.py index 1d63cd6..31d2fb3 100644 --- a/chianft/cmds/cli.py +++ b/chianft/cmds/cli.py @@ -120,9 +120,7 @@ def create_spend_bundles_cmd( """ async def do_command() -> None: - maybe_clients = await get_node_and_wallet_clients( - node_rpc_port, wallet_rpc_port, fingerprint - ) + maybe_clients = await get_node_and_wallet_clients(node_rpc_port, wallet_rpc_port, fingerprint) if maybe_clients is None: print("Failed to connect to wallet and node") return @@ -145,7 +143,7 @@ async def do_command() -> None: ) with open(bundle_output, "wb") as f: pickle.dump(spend_bundles, f) - print("Successfully created {} spend bundles".format(len(spend_bundles))) + print(f"Successfully created {len(spend_bundles)} spend bundles") finally: node_client.close() wallet_client.close() @@ -205,9 +203,7 @@ def submit_spend_bundles_cmd( """ async def do_command() -> None: - maybe_clients = await get_node_and_wallet_clients( - node_rpc_port, wallet_rpc_port, fingerprint - ) + maybe_clients = await get_node_and_wallet_clients(node_rpc_port, wallet_rpc_port, fingerprint) if maybe_clients is None: print("Failed to connect to wallet and node") return @@ -224,9 +220,7 @@ async def do_command() -> None: spends.append(SpendBundle.from_bytes(spend_bytes)) minter = Minter(wallet_client, node_client) - await minter.submit_spend_bundles( - spends, fee, create_sell_offer=create_sell_offer - ) + await minter.submit_spend_bundles(spends, fee, create_sell_offer=create_sell_offer) finally: node_client.close() diff --git a/chianft/util/clients.py b/chianft/util/clients.py index 77c0e7a..4fe2886 100644 --- a/chianft/util/clients.py +++ b/chianft/util/clients.py @@ -1,5 +1,7 @@ +from __future__ import annotations + from pprint import pprint -from typing import Optional, Tuple +from typing import Optional import aiohttp @@ -25,9 +27,7 @@ async def get_node_client( return full_node_client except Exception as e: if isinstance(e, aiohttp.ClientConnectorError): - pprint( - f"Connection error. Check if full node is running at {full_node_rpc_port}" - ) + pprint(f"Connection error. Check if full node is running at {full_node_rpc_port}") else: pprint(f"Exception from 'full node' {e}") return None @@ -41,9 +41,7 @@ async def get_wallet_client( config = load_config(DEFAULT_ROOT_PATH, "config.yaml") self_hostname = config["self_hostname"] wallet_rpc_port = config["wallet"]["rpc_port"] - wallet_client = await WalletRpcClient.create( - self_hostname, uint16(wallet_rpc_port), DEFAULT_ROOT_PATH, config - ) + wallet_client = await WalletRpcClient.create(self_hostname, uint16(wallet_rpc_port), DEFAULT_ROOT_PATH, config) return wallet_client except Exception as e: if isinstance(e, aiohttp.ClientConnectorError): @@ -57,7 +55,7 @@ async def get_node_and_wallet_clients( full_node_rpc_port: Optional[int], wallet_rpc_port: Optional[int], fingerprint: Optional[int], -) -> Optional[Tuple[Optional[FullNodeRpcClient], Optional[WalletRpcClient]]]: +) -> Optional[tuple[Optional[FullNodeRpcClient], Optional[WalletRpcClient]]]: try: full_node_client = await get_node_client(full_node_rpc_port) wallet_client = await get_wallet_client(wallet_rpc_port) @@ -76,8 +74,4 @@ async def get_node_and_wallet_clients( def get_additional_data() -> bytes: config = load_config(DEFAULT_ROOT_PATH, "config.yaml") selected_network = config["farmer"]["selected_network"] - return bytes.fromhex( - config["farmer"]["network_overrides"]["constants"][selected_network][ - "GENESIS_CHALLENGE" - ] - ) + return bytes.fromhex(config["farmer"]["network_overrides"]["constants"][selected_network]["GENESIS_CHALLENGE"]) diff --git a/chianft/util/mint.py b/chianft/util/mint.py index 26142cf..48372b7 100644 --- a/chianft/util/mint.py +++ b/chianft/util/mint.py @@ -3,7 +3,7 @@ import asyncio import csv from pathlib import Path -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Optional from chia.consensus.default_constants import DEFAULT_CONSTANTS from chia.rpc.full_node_rpc_client import FullNodeRpcClient @@ -37,21 +37,13 @@ async def get_wallet_ids( nft_wallets = await self.wallet_client.get_wallets(wallet_type=WalletType.NFT) if nft_wallet_id is not None: if len(nft_wallets) > 1: - self.non_did_nft_wallet_ids = [ - wallet["id"] - for wallet in nft_wallets - if wallet["id"] != nft_wallet_id - ] + self.non_did_nft_wallet_ids = [wallet["id"] for wallet in nft_wallets if wallet["id"] != nft_wallet_id] self.nft_wallet_id = nft_wallet_id self.did_coin_id = None self.did_wallet_id: int = 0 - did_id_for_nft = ( - await self.wallet_client.get_nft_wallet_did(wallet_id=nft_wallet_id) - )["did_id"] - did_wallets = await self.wallet_client.get_wallets( - wallet_type=WalletType.DECENTRALIZED_ID - ) + did_id_for_nft = (await self.wallet_client.get_nft_wallet_did(wallet_id=nft_wallet_id))["did_id"] + did_wallets = await self.wallet_client.get_wallets(wallet_type=WalletType.DECENTRALIZED_ID) for wallet in did_wallets: did_info = await self.wallet_client.get_did_id(wallet_id=wallet["id"]) if did_info["my_did"] == did_id_for_nft: @@ -61,17 +53,13 @@ async def get_wallet_ids( else: self.non_did_nft_wallet_ids = [] for wallet in nft_wallets: - did_id = ( - await self.wallet_client.get_nft_wallet_did(wallet_id=wallet["id"]) - )["did_id"] + did_id = (await self.wallet_client.get_nft_wallet_did(wallet_id=wallet["id"]))["did_id"] if did_id is None: self.non_did_nft_wallet_ids.append(wallet["id"]) else: self.nft_wallet_id = wallet["id"] - xch_wallets = await self.wallet_client.get_wallets( - wallet_type=WalletType.STANDARD_WALLET - ) + xch_wallets = await self.wallet_client.get_wallets(wallet_type=WalletType.STANDARD_WALLET) self.xch_wallet_id = xch_wallets[0]["id"] async def get_funding_coin(self, amount: int) -> Coin: @@ -81,15 +69,10 @@ async def get_funding_coin(self, amount: int) -> Coin: coin_selection_config=DEFAULT_COIN_SELECTION_CONFIG, ) if len(coins) > 1: - raise ValueError( - "Bulk minting requires a single coin with value greater than %s" - % amount - ) + raise ValueError(f"Bulk minting requires a single coin with value greater than {amount}") return coins[0] - async def get_tx_from_mempool( - self, sb_name: bytes32 - ) -> Tuple[bool, Optional[bytes32]]: + async def get_tx_from_mempool(self, sb_name: bytes32) -> tuple[bool, Optional[bytes32]]: mempool_items = await self.node_client.get_all_mempool_items() for item in mempool_items.items(): if bytes32(hexstr_to_bytes(item[1]["spend_bundle_name"])) == sb_name: @@ -106,29 +89,23 @@ async def create_spend_bundles( royalty_percentage: Optional[int] = 0, has_targets: Optional[bool] = True, chunk: Optional[int] = 25, - ) -> List[bytes]: + ) -> list[bytes]: await self.get_wallet_ids(wallet_id) - metadata_list, target_list = read_metadata_csv( - metadata_input, has_header=True, has_targets=has_targets - ) + metadata_list, target_list = read_metadata_csv(metadata_input, has_header=True, has_targets=has_targets) mint_total = len(metadata_list) funding_coin: Coin = await self.get_funding_coin(mint_total) next_coin = funding_coin spend_bundles = [] if mint_from_did: did = await self.wallet_client.get_did_id(wallet_id=self.did_wallet_id) - did_cr = await self.wallet_client.get_did_info( - coin_id=did["coin_id"], latest=True - ) - did_coin_record: Optional[CoinRecord] = ( - await self.node_client.get_coin_record_by_name( - bytes32.from_hexstr(did_cr["latest_coin"]) - ) + did_cr = await self.wallet_client.get_did_info(coin_id=did["coin_id"], latest=True) + did_coin_record: Optional[CoinRecord] = await self.node_client.get_coin_record_by_name( + bytes32.from_hexstr(did_cr["latest_coin"]) ) assert did_coin_record is not None did_coin = did_coin_record.coin assert did_coin is not None - did_coin_dict: Optional[Dict[str, Any]] = did_coin.to_json_dict() + did_coin_dict: Optional[dict[str, Any]] = did_coin.to_json_dict() else: did_coin = None did_coin_dict = None @@ -153,26 +130,20 @@ async def create_spend_bundles( tx_config=DEFAULT_TX_CONFIG, ) if not resp: - raise ValueError( - "SpendBundle could not be created for metadata rows: %s to %s" - % (i, i + chunk) - ) + raise ValueError(f"SpendBundle could not be created for metadata rows: {i} to {i + chunk}") sb = resp.spend_bundle spend_bundles.append(bytes(sb)) - next_coin = [ - c for c in sb.additions() if c.puzzle_hash == funding_coin.puzzle_hash - ][0] + next_coin = next(c for c in sb.additions() if c.puzzle_hash == funding_coin.puzzle_hash) if mint_from_did: assert did_coin is not None - did_lineage_parent = [ + did_lineage_parent = next( c for c in sb.removals() if c.name() == did_coin.name() - ][0].parent_coin_info.hex() - did_coin = [ + ).parent_coin_info.hex() + did_coin = next( c for c in sb.additions() - if (c.parent_coin_info == did_coin.name()) - and (c.amount == did_coin.amount) - ][0] + if (c.parent_coin_info == did_coin.name()) and (c.amount == did_coin.amount) + ) assert did_coin is not None did_coin_dict = did_coin.to_json_dict() return spend_bundles @@ -199,7 +170,7 @@ async def add_fee_to_spend( fee_coin: Coin, attempt: int, max_fee: Optional[int], - ) -> Tuple[SpendBundle, int]: + ) -> tuple[SpendBundle, int]: if max_fee: total_fee = max_fee else: @@ -223,7 +194,7 @@ async def add_fee_to_spend( # No fee required return spend, 0 total_fee = sb_cost * (fee_per_cost * attempt) - print("Fee for inclusion: {}".format(total_fee)) + print(f"Fee for inclusion: {total_fee}") fee_tx = await self.wallet_client.create_signed_transactions( additions=[ { @@ -250,11 +221,7 @@ async def tx_confirmed(self, sb: SpendBundle) -> bool: # grab the NFT coins from the spend and check if they are visible to the node_client # we can't check against wallet client b/c they might be transferred during the mint spend removal_ids = [coin.name() for coin in sb.removals() if coin.amount == 0] - nft_list = [ - coin - for coin in sb.additions() - if coin.amount == 1 and coin.parent_coin_info in removal_ids - ] + nft_list = [coin for coin in sb.additions() if coin.amount == 1 and coin.parent_coin_info in removal_ids] confirmed_nfts = 0 for nft in nft_list: # Retry up to 10 times to find NFTs on node @@ -269,11 +236,7 @@ async def tx_confirmed(self, sb: SpendBundle) -> bool: if confirmed_nfts == len(nft_list): return True else: - print( - "Only found {} of {} confirmed nfts".format( - confirmed_nfts, len(nft_list) - ) - ) + print(f"Only found {confirmed_nfts} of {len(nft_list)} confirmed nfts") return False async def monitor_mempool(self, sb: SpendBundle) -> bool: @@ -308,12 +271,9 @@ async def submit_spend( max_fee: Optional[int], ) -> SpendBundle: max_retries = 10 - total_fee = 0 for j in range(max_retries): - final_sb, total_fee = await self.add_fee_to_spend( - sb, fee_coin, j + 1, max_fee - ) - print("Submitting SB: {}".format(final_sb.name())) + final_sb, _total_fee = await self.add_fee_to_spend(sb, fee_coin, j + 1, max_fee) + print(f"Submitting SB: {final_sb.name()}") try: resp = await self.node_client.push_tx(final_sb) if resp["success"]: @@ -323,11 +283,7 @@ async def submit_spend( if tx_confirmed: return final_sb else: - print( - "Spend was kicked from mempool. Retrying {} of {}".format( - j, max_retries - ) - ) + print(f"Spend was kicked from mempool. Retrying {j} of {max_retries}") continue except ValueError as err: error_msg = err.args[0]["error"] @@ -340,24 +296,17 @@ async def submit_spend( raise ValueError("Submit spend failed. Wait for a few blocks and retry") - async def get_unspent_spend_bundle( - self, spend_bundles: List[SpendBundle] - ) -> Tuple[Coin, int]: + async def get_unspent_spend_bundle(self, spend_bundles: list[SpendBundle]) -> tuple[Coin, int]: for i, sb in enumerate(spend_bundles): - xch_coin_to_spend = [coin for coin in sb.removals() if coin.amount > 1][0] - coin_record = await self.node_client.get_coin_record_by_name( - xch_coin_to_spend.name() - ) + xch_coin_to_spend = next(coin for coin in sb.removals() if coin.amount > 1) + coin_record = await self.node_client.get_coin_record_by_name(xch_coin_to_spend.name()) assert coin_record is not None if coin_record.spent_block_index == 0: starting_spend_index: int = i return xch_coin_to_spend, starting_spend_index - else: - raise ValueError("All spend bundles have been spent") + raise ValueError("All spend bundles have been spent") - async def create_offer( - self, launcher_ids: List[str], create_sell_offer: int - ) -> None: + async def create_offer(self, launcher_ids: list[str], create_sell_offer: int) -> None: assert self.wallet_client is not None for launcher_id in launcher_ids: offer_dict = { @@ -372,7 +321,7 @@ async def create_offer( tx_config=DEFAULT_TX_CONFIG, ) offer = offer_resp.offer - filepath = "offers/{}.offer".format(launcher_id) + filepath = f"offers/{launcher_id}.offer" assert offer is not None with open(Path(filepath), "w") as file: file.write(offer.to_bech32()) @@ -382,7 +331,6 @@ async def create_offer( print("Retrying offer creation in 5 seconds") await asyncio.sleep(5) continue - return async def coin_in_mempool(self, funding_coin: Coin) -> Optional[SpendBundle]: # the raw spend bundle won't be included in mempool if it has fee added, so we have to check @@ -396,14 +344,14 @@ async def coin_in_mempool(self, funding_coin: Coin) -> Optional[SpendBundle]: async def submit_spend_bundles( self, - spend_bundles: List[SpendBundle], + spend_bundles: list[SpendBundle], fee: Optional[int] = None, create_sell_offer: Optional[int] = None, ) -> None: await self.get_wallet_ids() funding_coin, sb_index = await self.get_unspent_spend_bundle(spend_bundles) if sb_index > 0: - print("Resuming from spend bundle: {}".format(sb_index)) + print(f"Resuming from spend bundle: {sb_index}") # setup a directory for offers if needed if create_sell_offer: @@ -413,12 +361,8 @@ async def submit_spend_bundles( if fee: estimated_max_fee = len(spend_bundles) * fee else: - estimated_max_fee = ( - len(spend_bundles) * self.spend_cost(spend_bundles[0]) * 5 - ) - csc = DEFAULT_COIN_SELECTION_CONFIG.override( - excluded_coin_ids=[funding_coin.name()] - ) + estimated_max_fee = len(spend_bundles) * self.spend_cost(spend_bundles[0]) * 5 + csc = DEFAULT_COIN_SELECTION_CONFIG.override(excluded_coin_ids=[funding_coin.name()]) fee_coin = ( await self.wallet_client.select_coins( amount=estimated_max_fee, @@ -434,44 +378,34 @@ async def submit_spend_bundles( return None # Loop through the unspent bundles and try to submit them - print( - "Submitting a total of {} spend bundles".format( - len(spend_bundles[sb_index:]) - ) - ) + print(f"Submitting a total of {len(spend_bundles[sb_index:])} spend bundles") for i, sb in enumerate(spend_bundles[sb_index:]): final_sb = await self.submit_spend(i, sb, fee_coin, fee) - fee_coin_list = [ - coin - for coin in final_sb.additions() - if coin.parent_coin_info == fee_coin.name() - ] + fee_coin_list = [coin for coin in final_sb.additions() if coin.parent_coin_info == fee_coin.name()] if fee_coin_list: fee_coin = fee_coin_list[0] launcher_ids = [ - coin.name().hex() - for coin in sb.removals() - if coin.puzzle_hash == SINGLETON_LAUNCHER_PUZZLE_HASH + coin.name().hex() for coin in sb.removals() if coin.puzzle_hash == SINGLETON_LAUNCHER_PUZZLE_HASH ] if create_sell_offer: await self.create_offer(launcher_ids, create_sell_offer) - print("Spendbundle {} Confirmed".format(sb_index + i)) + print(f"Spendbundle {sb_index + i} Confirmed") bs = await self.node_client.get_blockchain_state() mempool_pc = bs["mempool_cost"] / bs["mempool_max_total_cost"] - print("Mempool utilization: {:.0%}".format(mempool_pc)) + print(f"Mempool utilization: {mempool_pc:.0%}") def read_metadata_csv( file_path: Path, has_header: Optional[bool] = False, has_targets: Optional[bool] = False, -) -> Tuple[List[Dict[str, Any]], List[str]]: - with open(file_path, "r") as f: +) -> tuple[list[dict[str, Any]], list[str]]: + with open(file_path) as f: csv_reader = csv.reader(f) bulk_data = list(csv_reader) - metadata_list: List[Dict[str, Any]] = [] + metadata_list: list[dict[str, Any]] = [] if has_header: header_row = bulk_data[0] rows = bulk_data[1:] @@ -492,9 +426,7 @@ def read_metadata_csv( list_headers = ["uris", "meta_uris", "license_uris"] targets = [] for row in rows: - meta_dict: Dict[str, Any] = { - list_headers[i]: [] for i in range(len(list_headers)) - } + meta_dict: dict[str, Any] = {list_headers[i]: [] for i in range(len(list_headers))} for i, header in enumerate(header_row): if header in list_headers: meta_dict[header].append(row[i]) diff --git a/factory_metadata.py b/factory_metadata.py index c75080f..8f470c6 100644 --- a/factory_metadata.py +++ b/factory_metadata.py @@ -1,8 +1,10 @@ +from __future__ import annotations + import asyncio import csv import sys from secrets import token_bytes -from typing import Any, List +from typing import Any from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.bech32m import encode_puzzle_hash @@ -11,7 +13,7 @@ fake = Faker() -async def create_nft_sample(has_targets: bool) -> List[Any]: +async def create_nft_sample(has_targets: bool) -> list[Any]: sample = [ bytes32(token_bytes(32)).hex(), # data_hash fake.image_url(), # data_url @@ -27,7 +29,7 @@ async def create_nft_sample(has_targets: bool) -> List[Any]: return sample -async def create_target_sample() -> List[Any]: +async def create_target_sample() -> list[Any]: return [encode_puzzle_hash(bytes32(token_bytes(32)), "txch")] @@ -48,19 +50,19 @@ async def main(count: int, has_targets: bool) -> None: data = await asyncio.gather(*coros) with open("metadata.csv", "w") as f: writer = csv.writer(f) - writer.writerows([header] + data) + writer.writerows([header, *data]) royalty_address = encode_puzzle_hash(bytes32(token_bytes(32)), "txch") royalty_basis_pts = 300 - print("Royalty Address: %s" % royalty_address) - print("Royalty Percent: %s" % royalty_basis_pts) + print(f"Royalty Address: {royalty_address}") + print(f"Royalty Percent: {royalty_basis_pts}") if __name__ == "__main__": params = sys.argv[1:] if "t" in params: has_targets = True - count = int(list(set(params) - set("t"))[0]) + count = int(next(iter(set(params) - set("t")))) else: has_targets = False count = int(params[0]) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..70f8c92 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = [ + "setuptools>=42", + "setuptools_scm[toml]>=4.1.2", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +fallback_version = "unknown-no-.git-directory" +local_scheme = "no-local-version" diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..35cabb8 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,95 @@ +line-length = 120 + +[lint] +preview = true +select = [ + "PL", # Pylint + "I", # Isort + "FA", # Flake8: future-annotations + "UP", # Pyupgrade + "RUF", # Ruff specific + "F", # Flake8 core + "ASYNC", # Flake8 async + "ISC", # flake8-implicit-str-concat + "TID", # flake8-tidy-imports + "E", + "W", +] +explicit-preview-rules = false +ignore = [ + # Pylint convention + "PLC0415", # import-outside-top-level + "PLC1901", # compare-to-empty-string + # Should probably fix these + "PLC2801", # unnecessary-dunder-call + "PLC2701", # import-private-name + + # Pylint refactor + "PLR0915", # too-many-statements + "PLR0914", # too-many-locals + "PLR0913", # too-many-arguments + "PLR0912", # too-many-branches + "PLR1702", # too-many-nested-blocks + "PLR0904", # too-many-public-methods + "PLR0917", # too-many-positional-arguments + "PLR0916", # too-many-boolean-expressions + "PLR0911", # too-many-return-statements + # Should probably fix these + "PLR6301", # no-self-use + "PLR2004", # magic-value-comparison + "PLR1704", # redefined-argument-from-local + "PLR5501", # collapsible-else-if + + # Pylint warning + "PLW1641", # eq-without-hash + # Should probably fix these + "PLW2901", # redefined-loop-name + "PLW1514", # unspecified-encoding + "PLW0603", # global-statement + + # Flake8 async + # Should probably fix these + "ASYNC230", # blocking-open-call-in-async-function + # Should probably fix these after dealing with shielding for anyio + "ASYNC109", # async-function-with-timeout + + # flake8-implicit-str-concat + "ISC003", # explicit-string-concatenation + + # Ruff Specific + + # This code is problematic because using instantiated types as defaults is so common across the codebase. + # Its purpose is to prevent accidenatally assigning mutable defaults. However, this is a bit overkill for that. + # That being said, it would be nice to add some way to actually guard against that specific mutable default behavior. + "RUF009", # function-call-in-dataclass-default-argument + # Should probably fix this + "RUF029", +] + + +[lint.flake8-implicit-str-concat] +# Found 3279 errors. +# allow-multiline = false + +[lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[lint.flake8-tidy-imports.banned-api] +# for use with another pr +# "asyncio.create_task".msg = "Use `from chia.util.pit import pit` and `pit.create_task()`" + +[lint.isort] +required-imports = ["from __future__ import annotations"] + +[lint.pylint] +max-args = 5 +max-locals = 15 +max-returns = 6 +max-branches = 12 +max-statements = 50 +max-nested-blocks = 5 +max-public-methods = 20 +max-bool-expr = 5 + +[lint.pyupgrade] +keep-runtime-typing = true diff --git a/setup.py b/setup.py index f49566f..6308d6b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ +from __future__ import annotations + from setuptools import find_packages, setup -with open("README.md", "rt", encoding="UTF-8") as fh: +with open("README.md", encoding="UTF-8") as fh: long_description = fh.read() dependencies = [ @@ -8,24 +10,19 @@ ] dev_dependencies = [ - "pylint==3.3.2", "pytest==8.3.4", "pytest-asyncio==0.25.0", "pytest-monitor==1.6.6; sys_platform == 'linux'", "pytest-xdist==3.6.1", - "isort==5.13.2", + "ruff>=0.8.1", "faker==33.1.0", - "flake8==7.1.1", "mypy==1.13.0", - "black==24.10.0", "types-setuptools==75.6.0.20241126", - "pre-commit==3.5.0; python_version < '3.9'", "pre-commit==4.0.1; python_version >= '3.9'", ] setup( name="chianft", - version="0.1", packages=find_packages(exclude=("tests",)), author="Geoff Walmsley", entry_points={ @@ -38,7 +35,7 @@ setup_requires=["setuptools_scm"], install_requires=dependencies, url="https://github.com/Chia-Network", - license="https://opensource.org/licenses/Apache-2.0", + license="Apache-2.0", description="Chia NFT minting toolkit", long_description=long_description, long_description_content_type="text/markdown", @@ -47,6 +44,7 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: Apache Software License", "Topic :: Security :: Cryptography", ], diff --git a/tests/test_mint.py b/tests/test_mint.py index 962014d..a4ca6df 100644 --- a/tests/test_mint.py +++ b/tests/test_mint.py @@ -76,9 +76,7 @@ def test_mint_from_did(has_targets: bool) -> None: output_file, ], ) - result = runner.invoke( - cli, ["submit-spend-bundles", "--fee", str(10), output_file] - ) + result = runner.invoke(cli, ["submit-spend-bundles", "--fee", str(10), output_file]) # traceback.print_exception(*result.exc_info) # breakpoint() @@ -116,9 +114,7 @@ def test_mint_from_xch(has_targets: bool) -> None: ], ) - result = runner.invoke( - cli, ["submit-spend-bundles", "--fee", "10", output_file] - ) + result = runner.invoke(cli, ["submit-spend-bundles", "--fee", "10", output_file]) # traceback.print_exception(*result.exc_info) # breakpoint()