From b91b9193a0cf374afb97e7ca97cb52ac9fa8f763 Mon Sep 17 00:00:00 2001 From: NotPeopling2day <32708219+NotPeopling2day@users.noreply.github.com> Date: Fri, 10 Nov 2023 17:06:34 +0100 Subject: [PATCH] chore: update repo --- .github/release-drafter.yml | 4 +- .github/workflows/codeql.yaml | 34 +++++++++++++++++ .github/workflows/commitlint.yaml | 8 ++-- .github/workflows/draft.yaml | 2 + .../workflows/{title.yaml => prtitle.yaml} | 6 +-- .github/workflows/publish.yaml | 8 ++-- .github/workflows/test.yaml | 38 ++++++++++++------- .pre-commit-config.yaml | 8 ++-- CONTRIBUTING.md | 2 +- ape_frame/exceptions.py | 15 +++++++- pyproject.toml | 3 ++ setup.py | 20 ++++++---- tests/test_accounts.py | 13 +++++++ 13 files changed, 121 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/codeql.yaml rename .github/workflows/{title.yaml => prtitle.yaml} (79%) create mode 100644 tests/test_accounts.py diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 70b2a3f..a2beeef 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -31,7 +31,7 @@ version-resolver: template: | ## Changes - + $CHANGES - + Special thanks to: $CONTRIBUTORS diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml new file mode 100644 index 0000000..2cdc07b --- /dev/null +++ b/.github/workflows/codeql.yaml @@ -0,0 +1,34 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: python + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml index c376171..d63f5a2 100644 --- a/.github/workflows/commitlint.yaml +++ b/.github/workflows/commitlint.yaml @@ -9,17 +9,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install Dependencies - run: pip install .[dev] + run: pip install commitizen - name: Check commit history run: cz check --rev-range $(git rev-list --all --reverse | head -1)..HEAD diff --git a/.github/workflows/draft.yaml b/.github/workflows/draft.yaml index 423582b..f136f49 100644 --- a/.github/workflows/draft.yaml +++ b/.github/workflows/draft.yaml @@ -8,6 +8,8 @@ on: jobs: update-draft: runs-on: ubuntu-latest + permissions: + contents: write steps: # Drafts your next Release notes as Pull Requests are merged into "main" - uses: release-drafter/release-drafter@v5 diff --git a/.github/workflows/title.yaml b/.github/workflows/prtitle.yaml similarity index 79% rename from .github/workflows/title.yaml rename to .github/workflows/prtitle.yaml index d283678..a6cd3b0 100644 --- a/.github/workflows/title.yaml +++ b/.github/workflows/prtitle.yaml @@ -12,12 +12,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install Dependencies run: pip install commitizen diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a1b9019..2c88013 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,18 +10,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e .[release] - + - name: Build run: python setup.py sdist bdist_wheel diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5489395..8883134 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,17 +2,24 @@ on: ["push", "pull_request"] name: Test +concurrency: + # Cancel older, in-progress jobs from the same PR, same workflow. + # use run_id if the job is triggered by a push to ensure + # push-triggered jobs to not get canceled. + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install Dependencies run: | @@ -22,22 +29,25 @@ jobs: - name: Run Black run: black --check . + - name: Run isort + run: isort --check-only . + - name: Run flake8 run: flake8 . - - name: Run isort - run: isort --check-only . + - name: Run mdformat + run: mdformat . --check type-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install Dependencies run: | @@ -53,13 +63,13 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] # eventually add `windows-latest` - python-version: [3.8, 3.9, "3.10"] + python-version: [3.8, 3.9, "3.10", "3.11"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -79,12 +89,12 @@ jobs: # fail-fast: true # # steps: -# - uses: actions/checkout@v2 +# - uses: actions/checkout@v3 # # - name: Setup Python -# uses: actions/setup-python@v2 +# uses: actions/setup-python@v4 # with: -# python-version: 3.8 +# python-version: "3.10" # # - name: Install Dependencies # run: pip install .[test] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a871415..0fb78ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.5.0 hooks: - id: check-yaml @@ -10,18 +10,18 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.11.0 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v1.6.1 hooks: - id: mypy additional_dependencies: [types-requests, types-setuptools] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4028a76..1a4b969 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,4 +46,4 @@ A pull request represents the start of a discussion, and doesn't necessarily nee If you are opening a work-in-progress pull request to verify that it passes CI tests, please consider [marking it as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests). -Join the Ethereum Python [Discord](https://discord.gg/PcEJ54yX) if you have any questions. +Join the ApeWorX [Discord](https://discord.gg/apeworx) if you have any questions. diff --git a/ape_frame/exceptions.py b/ape_frame/exceptions.py index ec78063..5d2e8af 100644 --- a/ape_frame/exceptions.py +++ b/ape_frame/exceptions.py @@ -1,4 +1,4 @@ -from ape.exceptions import ProviderError, ProviderNotConnectedError +from ape.exceptions import AccountsError, ProviderError, ProviderNotConnectedError class FrameNotConnectedError(ProviderNotConnectedError): @@ -9,3 +9,16 @@ class FrameProviderError(ProviderError): """ An error raised by the Frame provider plugin. """ + + +class FrameAccountException(AccountsError): + """ + An error that occurs in the ape Frame plugin. + """ + + +class FrameSigningError(FrameAccountException): + """ + An error that occurs when signing a message or transaction + using the Frame plugin. + """ diff --git a/pyproject.toml b/pyproject.toml index a6ee970..354c306 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,3 +37,6 @@ force_grid_wrap = 0 include_trailing_comma = true multi_line_output = 3 use_parentheses = true + +[tool.mdformat] +number = true diff --git a/setup.py b/setup.py index 3b3b194..b67b76f 100644 --- a/setup.py +++ b/setup.py @@ -5,16 +5,21 @@ extras_require = { "test": [ # `test` GitHub Action jobs uses this "pytest>=6.0", # Core testing package - "pytest-xdist", # multi-process runner + "pytest-xdist", # Multi-process runner "pytest-cov", # Coverage analyzer plugin "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer ], "lint": [ - "black>=22.10.0", # auto-formatter and linter - "mypy>=0.982", # Static type analyzer - "types-setuptools", # Needed for mypy type shed - "flake8>=5.0.4", # Style linter - "isort>=5.10.1", # Import sorting linter + "black>=23.11.0,<24", # Auto-formatter and linter + "mypy>=1.6.1,<2", # Static type analyzer + "types-requests", # Needed due to mypy typeshed + "types-setuptools", # Needed due to mypy typeshed + "types-PyYAML", # Needed due to mypy typeshed + "flake8>=6.1.0,<7", # Style linter + "isort>=5.10.1,<6", # Import sorting linter + "mdformat>=0.7.17", # Auto-formatter for markdown + "mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown + "mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates ], "release": [ # `release` GitHub Action job uses this "setuptools", # Installation tool @@ -65,7 +70,7 @@ packages=find_packages(exclude=["tests", "tests.*"]), package_data={"ape_frame": ["py.typed"]}, classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", @@ -75,5 +80,6 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], ) diff --git a/tests/test_accounts.py b/tests/test_accounts.py new file mode 100644 index 0000000..d2c42cc --- /dev/null +++ b/tests/test_accounts.py @@ -0,0 +1,13 @@ +import tempfile +from pathlib import Path + +from ape_frame.accounts import AccountContainer, FrameAccount + + +class TestAccountContainer: + def test_account_container(self): + with tempfile.TemporaryDirectory() as temp_dir: + data_path = Path(temp_dir) + container = AccountContainer(data_folder=data_path, account_type=FrameAccount) + for acct in container.accounts: + assert type(acct) is FrameAccount