From 0c3981c15895764cf9f1d357420df9732cfaa250 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 24 Aug 2023 12:55:20 -0500 Subject: [PATCH 1/4] blockchain 2.0.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a597d74..271a924 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ "pytest-asyncio", "pytimeparse", "anyio", - "chia-blockchain==1.8.1", + "chia-blockchain==2.0.0", ] dev_dependencies = [ From fd0465cdaa325e38c71c61406c27e6aa7e03e041 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Tue, 29 Aug 2023 16:06:21 -0700 Subject: [PATCH 2/4] Update for chia-blockchain 2.0.0 --- .isort.cfg | 5 +++++ .pre-commit-config.yaml | 9 ++++++--- activated.py | 2 ++ cdv/__init__.py | 2 ++ cdv/cmds/chia_inspect.py | 7 ++++++- cdv/cmds/cli.py | 2 ++ cdv/cmds/clsp.py | 4 +++- cdv/cmds/rpc.py | 2 ++ cdv/cmds/util.py | 2 ++ cdv/examples/drivers/piggybank_drivers.py | 2 ++ cdv/examples/tests/test_piggybank.py | 2 ++ cdv/test/__init__.py | 2 ++ cdv/test/test_skeleton.py | 2 ++ cdv/util/keys.py | 2 ++ cdv/util/load_clvm.py | 2 ++ setup.py | 4 +++- tests/build-init-files.py | 2 ++ tests/cmds/test_cdv.py | 2 ++ tests/cmds/test_clsp.py | 2 ++ tests/cmds/test_inspect.py | 2 ++ 20 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 .isort.cfg diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..7557202 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,5 @@ +[settings] +line_length = 120 +profile=black +skip_gitignore=true +add_imports=from __future__ import annotations diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f8cfaf..4a38e99 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,11 +38,14 @@ repos: - id: check-merge-conflict - id: check-ast - id: debug-statements -- repo: https://github.com/psf/black - rev: 21.12b0 +- repo: local hooks: - id: black - additional_dependencies: ['click<8.1'] + name: black + entry: ./activated.py black + language: system + require_serial: true + types_or: [python, pyi] - repo: https://github.com/pycqa/flake8 rev: 6.0.0 hooks: diff --git a/activated.py b/activated.py index 74c8902..c1a9969 100755 --- a/activated.py +++ b/activated.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +from __future__ import annotations + import os import pathlib import subprocess diff --git a/cdv/__init__.py b/cdv/__init__.py index 65a2efc..116092a 100644 --- a/cdv/__init__.py +++ b/cdv/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pkg_resources import DistributionNotFound, get_distribution try: diff --git a/cdv/cmds/chia_inspect.py b/cdv/cmds/chia_inspect.py index 4209705..6cedeb5 100644 --- a/cdv/cmds/chia_inspect.py +++ b/cdv/cmds/chia_inspect.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import sys from pprint import pprint @@ -80,6 +82,7 @@ def inspect_callback( # Utility functions + # If there's only one key, return the data on that key instead (for things like {'spend_bundle': {...}}) def json_and_key_strip(input: str) -> Dict: json_dict: Dict = json.loads(input) @@ -315,6 +318,7 @@ def do_inspect_coin_spend_cmd( INFINITE_COST, height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT, # so that all opcodes are available mempool_mode=True, + constants=DEFAULT_CONSTANTS, ) cost: int = npc_result.cost if ignore_byte_cost: @@ -403,6 +407,7 @@ def do_inspect_spend_bundle_cmd( INFINITE_COST, height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT, # so that all opcodes are available mempool_mode=True, + constants=DEFAULT_CONSTANTS, ) cost: int = npc_result.cost if kwargs["ignore_byte_cost"]: @@ -438,7 +443,7 @@ def do_inspect_spend_bundle_cmd( ] for pk, msg in pkm_pairs_for_conditions_dict( conditions_dict, - coin_spend.coin.name(), + coin_spend.coin, hexstr_to_bytes(genesis_challenge), ): if str(pk) in pkm_dict: diff --git a/cdv/cmds/cli.py b/cdv/cmds/cli.py index b926610..2afa02e 100644 --- a/cdv/cmds/cli.py +++ b/cdv/cmds/cli.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil from pathlib import Path diff --git a/cdv/cmds/clsp.py b/cdv/cmds/clsp.py index bd67e5c..acf2689 100644 --- a/cdv/cmds/clsp.py +++ b/cdv/cmds/clsp.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil from pathlib import Path @@ -156,7 +158,7 @@ def uncurry_cmd(program: str, treehash: bool, dump: bool): ) def cat_puzzle_hash(inner_puzzlehash: str, tail_hash: str): from chia.wallet.cat_wallet.cat_constants import DEFAULT_CATS - from chia.wallet.puzzles.cat_loader import CAT_MOD + from chia.wallet.cat_wallet.cat_utils import CAT_MOD default_cats_by_symbols = {cat["symbol"]: cat for cat in DEFAULT_CATS.values()} if tail_hash in default_cats_by_symbols: diff --git a/cdv/cmds/rpc.py b/cdv/cmds/rpc.py index f81ab97..a6bfa86 100644 --- a/cdv/cmds/rpc.py +++ b/cdv/cmds/rpc.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import json from pprint import pprint diff --git a/cdv/cmds/util.py b/cdv/cmds/util.py index 3f06a3b..6e66c56 100644 --- a/cdv/cmds/util.py +++ b/cdv/cmds/util.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import re from typing import Dict, Iterable, List, Union diff --git a/cdv/examples/drivers/piggybank_drivers.py b/cdv/examples/drivers/piggybank_drivers.py index 5e9fefc..6956bf2 100644 --- a/cdv/examples/drivers/piggybank_drivers.py +++ b/cdv/examples/drivers/piggybank_drivers.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from typing import List diff --git a/cdv/examples/tests/test_piggybank.py b/cdv/examples/tests/test_piggybank.py index 3f76b51..ef51b4b 100644 --- a/cdv/examples/tests/test_piggybank.py +++ b/cdv/examples/tests/test_piggybank.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Dict, List, Optional import pytest diff --git a/cdv/test/__init__.py b/cdv/test/__init__.py index f2c5a6a..30555ff 100644 --- a/cdv/test/__init__.py +++ b/cdv/test/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import binascii import datetime import struct diff --git a/cdv/test/test_skeleton.py b/cdv/test/test_skeleton.py index cf46d29..4fbfe97 100644 --- a/cdv/test/test_skeleton.py +++ b/cdv/test/test_skeleton.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest import pytest_asyncio diff --git a/cdv/util/keys.py b/cdv/util/keys.py index 7b7c9bb..bf8e5af 100644 --- a/cdv/util/keys.py +++ b/cdv/util/keys.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Dict, List from blspy import AugSchemeMPL, BasicSchemeMPL, G1Element, G2Element, PrivateKey diff --git a/cdv/util/load_clvm.py b/cdv/util/load_clvm.py index 672b2b8..56fef34 100644 --- a/cdv/util/load_clvm.py +++ b/cdv/util/load_clvm.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import inspect import os diff --git a/setup.py b/setup.py index 271a924..d40254a 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import annotations + from setuptools import find_packages, setup with open("README.md", "rt") as fh: @@ -18,13 +20,13 @@ "anyio", "flake8", "mypy", + "black==23.7.0", "types-aiofiles", "types-click", "types-cryptography", "types-pkg_resources", "types-pyyaml", "types-setuptools", - "black==21.12b0", "isort", "pre-commit", "pylint", diff --git a/tests/build-init-files.py b/tests/build-init-files.py index 35f5a2d..009e9d2 100644 --- a/tests/build-init-files.py +++ b/tests/build-init-files.py @@ -9,6 +9,8 @@ # # Note: This script is run in a `pre-commit` hook (which runs on CI) to make sure we don't miss out any folder. +from __future__ import annotations + import logging import pathlib import sys diff --git a/tests/cmds/test_cdv.py b/tests/cmds/test_cdv.py index 8d0e1e7..900d528 100644 --- a/tests/cmds/test_cdv.py +++ b/tests/cmds/test_cdv.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from click.testing import CliRunner, Result diff --git a/tests/cmds/test_clsp.py b/tests/cmds/test_clsp.py index 92feca4..c1b640b 100644 --- a/tests/cmds/test_clsp.py +++ b/tests/cmds/test_clsp.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil from pathlib import Path diff --git a/tests/cmds/test_inspect.py b/tests/cmds/test_inspect.py index 1371462..6f892d6 100644 --- a/tests/cmds/test_inspect.py +++ b/tests/cmds/test_inspect.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json from pathlib import Path from typing import Dict, List From d1e696a515c4f1d14de13d453d3f98cdcf8d0196 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Tue, 29 Aug 2023 16:10:53 -0700 Subject: [PATCH 3/4] Remove python 3.7 and add python 3.11 --- .github/workflows/publish-to-pypi.yml | 4 ++-- .github/workflows/run-test-suite.yml | 15 ++++----------- .github/workflows/test-blockchain-main.yml | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index a9343b9..57632f2 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -25,10 +25,10 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python 3.7 + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: - python-version: "3.7" + python-version: "3.8" - name: Install build tools (pep517 compatible) run: >- diff --git a/.github/workflows/run-test-suite.yml b/.github/workflows/run-test-suite.yml index ccfbd18..96f887e 100644 --- a/.github/workflows/run-test-suite.yml +++ b/.github/workflows/run-test-suite.yml @@ -43,17 +43,14 @@ jobs: runs-on: intel: [windows-latest] python: - - major-dot-minor: '3.7' - matrix: '3.7' - major-dot-minor: '3.8' matrix: '3.8' - major-dot-minor: '3.9' matrix: '3.9' - major-dot-minor: '3.10' matrix: '3.10' -# TODO: add back once we bump have a blockchain dep that supports 3.11 -# - major-dot-minor: '3.11' -# matrix: '3.11' + - major-dot-minor: '3.11' + matrix: '3.11' arch: - name: ARM matrix: arm @@ -64,10 +61,6 @@ jobs: matrix: windows arch: matrix: arm - - os: - matrix: macos - python: - matrix: '3.7' - os: matrix: macos python: @@ -104,7 +97,7 @@ jobs: . ./venv/bin/activate pip install ."[dev]" ./venv/bin/chia init - ./venv/bin/py.test tests/ cdv/examples/tests -s -v --durations 0 + ./venv/bin/pytest tests/ cdv/examples/tests -s -v --durations 0 - name: Test code with pytest if: runner.os == 'Windows' @@ -112,4 +105,4 @@ jobs: run: | pip install .[dev] chia init - py.test tests\ cdv\examples\tests -s -v --durations 0 + pytest tests\ cdv\examples\tests -s -v --durations 0 diff --git a/.github/workflows/test-blockchain-main.yml b/.github/workflows/test-blockchain-main.yml index 7fb4866..bb7994e 100644 --- a/.github/workflows/test-blockchain-main.yml +++ b/.github/workflows/test-blockchain-main.yml @@ -42,4 +42,4 @@ jobs: sed -i 's/chia-blockchain.*/chia-blockchain @ git+https:\/\/github.com\/Chia-Network\/chia-blockchain.git@main\",/g' setup.py pip install ."[dev]" ./venv/bin/chia init - ./venv/bin/py.test tests/ cdv/examples/tests -s -v --durations 0 + ./venv/bin/pytest tests/ cdv/examples/tests -s -v --durations 0 From 03eac386f285e1a60c34b6386eb1c4e4174c6b79 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Tue, 29 Aug 2023 16:23:13 -0700 Subject: [PATCH 4/4] use black without activated --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a38e99..e749d1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: hooks: - id: black name: black - entry: ./activated.py black + entry: black language: system require_serial: true types_or: [python, pyi]