From 32fac35af469d0be208760d1a05323fe3a34f6ee Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Tue, 31 Jan 2023 13:30:55 -0600 Subject: [PATCH] chore: upgrade to 0.6 (#10) --- .github/ISSUE_TEMPLATE/bug.md | 15 +++++----- .github/ISSUE_TEMPLATE/feature.md | 6 ++-- .github/ISSUE_TEMPLATE/work-item.md | 21 ++++++++----- .github/PULL_REQUEST_TEMPLATE.md | 1 + .github/workflows/commitlint.yaml | 4 +-- .../workflows/{title.yaml => prtitle.yaml} | 4 +-- .github/workflows/publish.yaml | 4 +-- .github/workflows/test.yaml | 30 ++++++++++++------- .gitignore | 4 +++ .mdformat.toml | 1 + .pre-commit-config.yaml | 15 ++++++---- README.md | 2 +- ape_bsc/ecosystem.py | 12 ++++---- pyproject.toml | 1 + setup.py | 18 ++++++----- tests/test_integration.py | 25 ++++++++-------- 16 files changed, 100 insertions(+), 63 deletions(-) rename .github/workflows/{title.yaml => prtitle.yaml} (86%) create mode 100644 .mdformat.toml diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index a10cba0..d628c2a 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,11 +1,12 @@ --- name: Bug report about: Report an error that you've encountered. -labels: 'bug' +labels: bug --- + ### Environment information -* `ape` and plugin versions: +- `ape` and plugin versions: ``` $ ape --version @@ -15,16 +16,16 @@ $ ape plugins list # ...copy and paste result of above command here... ``` -* Python Version: x.x.x -* OS: macOS/linux/win +- Python Version: x.x.x +- OS: macOS/linux/win ### What went wrong? Please include information like: -* what command you ran -* the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code) -* full output of the error you received +- what command you ran +- the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code) +- full output of the error you received ### How can it be fixed? diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md index 742ce66..1b56056 100644 --- a/.github/ISSUE_TEMPLATE/feature.md +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -1,15 +1,15 @@ --- name: Feature request about: Request a new feature, or an improvement to existing functionality. -labels: 'enhancement' +labels: enhancement --- ### Overview Provide a simple overview of what you wish to see added. Please include: -* What you are trying to do -* Why Ape's current functionality is inadequate to address your goal +- What you are trying to do +- Why Ape's current functionality is inadequate to address your goal ### Specification diff --git a/.github/ISSUE_TEMPLATE/work-item.md b/.github/ISSUE_TEMPLATE/work-item.md index 3aa53f5..1932055 100644 --- a/.github/ISSUE_TEMPLATE/work-item.md +++ b/.github/ISSUE_TEMPLATE/work-item.md @@ -1,14 +1,15 @@ --- name: Work item about: New work item for Ape team -labels: 'backlog' - +labels: backlog --- ### Elevator pitch: + ### Value: + ### Dependencies: + ### Design approach: + ### Task list: + -* [ ] Tasks go here -### Estimated completion date: +- [ ] Tasks go here +### Estimated completion date: ### Design review: + + Do not signoff unless: -- 1) agreed the tasks and design approach will achieve acceptance, and -- 2) the work can be completed by one person within the SLA. -Design reviewers should consider simpler approaches to achieve goals. + +- 1. agreed the tasks and design approach will achieve acceptance, and +- 2. the work can be completed by one person within the SLA. + Design reviewers should consider simpler approaches to achieve goals. (Please leave a comment to sign off) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1d93a39..544cbc6 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,7 @@ ### What I did + fixes: # ### How I did it diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml index 9ca86eb..8eef089 100644 --- a/.github/workflows/commitlint.yaml +++ b/.github/workflows/commitlint.yaml @@ -9,12 +9,12 @@ 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 diff --git a/.github/workflows/title.yaml b/.github/workflows/prtitle.yaml similarity index 86% rename from .github/workflows/title.yaml rename to .github/workflows/prtitle.yaml index d283678..e52d792 100644 --- a/.github/workflows/title.yaml +++ b/.github/workflows/prtitle.yaml @@ -12,10 +12,10 @@ 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 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a1b9019..736a2f3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,10 +10,10 @@ 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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5489395..6454b89 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,15 +2,22 @@ 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 @@ -22,20 +29,23 @@ 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 @@ -56,10 +66,10 @@ jobs: python-version: [3.8, 3.9, "3.10"] 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,10 +89,10 @@ 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 # diff --git a/.gitignore b/.gitignore index 44faecd..7881af6 100644 --- a/.gitignore +++ b/.gitignore @@ -119,3 +119,7 @@ version.py # Ape stuff .build/ + +**/.DS_Store +*.swp +*.swo diff --git a/.mdformat.toml b/.mdformat.toml new file mode 100644 index 0000000..01b2fb0 --- /dev/null +++ b/.mdformat.toml @@ -0,0 +1 @@ +number = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29caddf..b402841 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,22 +10,27 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.12.0 hooks: - id: black name: black -- repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 +- repo: https://github.com/pycqa/flake8 + rev: 5.0.4 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v0.991 hooks: - id: mypy - additional_dependencies: [types-PyYAML, types-requests] + additional_dependencies: [types-setuptools, pydantic] +- repo: https://github.com/executablebooks/mdformat + rev: 0.7.14 + hooks: + - id: mdformat + additional_dependencies: [mdformat-gfm, mdformat-frontmatter] default_language_version: python: python3 diff --git a/README.md b/README.md index 60ab646..16693ef 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Ecosystem Plugin for Binance Smart Chain support in Ape. ## Dependencies -* [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev +- [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev ## Installation diff --git a/ape_bsc/ecosystem.py b/ape_bsc/ecosystem.py index b574669..508f31b 100644 --- a/ape_bsc/ecosystem.py +++ b/ape_bsc/ecosystem.py @@ -1,3 +1,5 @@ +from typing import cast + from ape.api.config import PluginConfig from ape.api.networks import LOCAL_NETWORK_NAME from ape_ethereum.ecosystem import Ethereum, NetworkConfig @@ -10,13 +12,13 @@ class BSCConfig(PluginConfig): - mainnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=3) # type: ignore - testnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=3) # type: ignore - local: NetworkConfig = NetworkConfig(default_provider="test") # type: ignore + mainnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=3) + testnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=3) + local: NetworkConfig = NetworkConfig(default_provider="test") default_network: str = LOCAL_NETWORK_NAME class BSC(Ethereum): @property - def config(self) -> BSCConfig: # type: ignore - return self.config_manager.get_config("bsc") # type: ignore + def config(self) -> BSCConfig: # type: ignore[override] + return cast(BSCConfig, self.config_manager.get_config("bsc")) diff --git a/pyproject.toml b/pyproject.toml index c99266e..5a54bae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"] [tool.mypy] exclude = "build/" +plugins = ["pydantic.mypy"] [tool.setuptools_scm] write_to = "ape_bsc/version.py" diff --git a/setup.py b/setup.py index 3023585..a6b8459 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,23 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from setuptools import find_packages, setup # type: ignore +from setuptools import find_packages, setup extras_require = { "test": [ # `test` GitHub Action jobs uses this - "pytest>=6.0,<7.0", # Core testing package + "pytest>=6.0", # Core testing package "pytest-xdist", # multi-process runner "pytest-cov", # Coverage analyzer plugin "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer ], "lint": [ - "black>=22.6.0,<23.0", # auto-formatter and linter - "mypy>=0.971,<1.0", # Static type analyzer - "flake8>=4.0.1,<5.0", # Style linter - "isort>=5.10.1,<6.0", # Import sorting linter + "black>=22.12.0", # auto-formatter and linter + "mypy>=0.991", # Static type analyzer + "flake8>=5.0.4", # Style linter + "isort>=5.10.1", # Import sorting linter + "types-setuptools", # Needed due to mypy typeshed + "mdformat>=0.7.16", # 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 @@ -53,7 +57,7 @@ url="https://github.com/ApeWorX/ape-bsc", include_package_data=True, install_requires=[ - "eth-ape>=0.5.0,<0.6", + "eth-ape>=0.6.0,<0.7", ], python_requires=">=3.8,<4", extras_require=extras_require, diff --git a/tests/test_integration.py b/tests/test_integration.py index ead53a3..fc3f15e 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -13,20 +13,21 @@ def assert_rich_text(actual: str, expected: str): """ The output from `rich` causes a bunch of extra spaces to appear at the end of each line. For easier testing, we remove those here. + Also, we ignore whether the expected line is at the end or in the middle + of the output to handle cases when the test-runner has additional plugins + installed. """ - actual = f"bsc{actual.split('bsc')[-1]}" - if "ethereum" in actual: - actual = actual.split("ethereum")[0] + expected_lines = [ + x.replace("└", "").replace("├", "").replace("│", "").strip() + for x in expected.strip().split("\n") + ] + actual_lines = [ + x.replace("└", "").replace("├", "").replace("│", "").strip() + for x in actual.strip().split("\n") + ] - expected = expected.strip() - lines = actual.split("\n") - new_lines = [] - for line in lines: - if line: - new_lines.append(line.rstrip()) - - actual = "\n".join(new_lines) - assert actual == expected + for expected_line in expected_lines: + assert expected_line in actual_lines def test_networks(runner, cli):