From 81e9d99cca00ee2e6f23af069597d185752b8083 Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Thu, 16 Jun 2022 19:08:49 -0500 Subject: [PATCH] feat: upgrade ape --- .github/workflows/commitlint.yaml | 4 +++- .github/workflows/test.yaml | 12 ++++++++--- .pre-commit-config.yaml | 11 +++-------- CONTRIBUTING.md | 10 +++++----- pyproject.toml | 5 +---- setup.py | 10 +++++----- tests/{.gitkeep => __init__.py} | 0 tests/conftest.py | 13 ++++++++++++ tests/test_integration.py | 33 +++++++++++++++++++++++++++++++ 9 files changed, 72 insertions(+), 26 deletions(-) rename tests/{.gitkeep => __init__.py} (100%) create mode 100644 tests/conftest.py create mode 100644 tests/test_integration.py diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml index c376171..9ca86eb 100644 --- a/.github/workflows/commitlint.yaml +++ b/.github/workflows/commitlint.yaml @@ -19,7 +19,9 @@ jobs: python-version: 3.8 - name: Install Dependencies - run: pip install .[dev] + run: | + python -m pip install --upgrade pip + 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/test.yaml b/.github/workflows/test.yaml index 2a5130d..d4dbaf8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,9 @@ jobs: python-version: 3.8 - name: Install Dependencies - run: pip install .[lint] + run: | + python -m pip install --upgrade pip + pip install .[lint] - name: Run Black run: black --check . @@ -38,7 +40,9 @@ jobs: python-version: 3.8 - name: Install Dependencies - run: pip install .[lint,test] # Might need test deps + run: | + python -m pip install --upgrade pip + pip install .[lint,test] - name: Run MyPy run: mypy . @@ -60,7 +64,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Dependencies - run: pip install .[test] + run: | + python -m pip install --upgrade pip + pip install .[test] # - name: Run Tests # run: pytest -m "not fuzzing" -n 0 -s --cov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f4bc8d..3daf1a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,9 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.2.0 hooks: - id: check-yaml -- repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: @@ -21,12 +16,12 @@ repos: name: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910-1 + rev: v0.961 hooks: - id: mypy additional_dependencies: [types-PyYAML, types-requests] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 49df2f4..b1bdc92 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,15 +3,15 @@ To get started with working on the codebase, use the following steps prepare your local environment: ```bash -# clone the github repo and navigate into the folder -git clone https://github.com/ApeWorX/ape-fantom.git -cd ape-fantom +# Clone the github repo and navigate into the folder +git clone https://github.com/ApeWorX/ape-bsc.git +cd ape-bsc -# create and load a virtual environment +# Create and load a virtual environment python3 -m venv venv source venv/bin/activate -# install brownie into the virtual environment +# Install ape into the virtual environment python setup.py install # install the developer dependencies (-e is interactive mode) diff --git a/pyproject.toml b/pyproject.toml index fa5aa87..8c80410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,12 +14,11 @@ write_to = "ape_bsc/version.py" [tool.black] line-length = 100 -target-version = ['py37', 'py38', 'py39'] +target-version = ['py37', 'py38', 'py39', 'py310'] include = '\.pyi?$' [tool.pytest.ini_options] addopts = """ - -n auto -p no:ape_test --cov-branch --cov-report term @@ -35,7 +34,5 @@ markers = "fuzzing: Run Hypothesis fuzz test suite" line_length = 100 force_grid_wrap = 0 include_trailing_comma = true -known_third_party = ["ape", "ape_ethereum", "ape_geth", "ape_test", "setuptools"] -known_first_party = ["ape_bsc"] multi_line_output = 3 use_parentheses = true diff --git a/setup.py b/setup.py index 7ce8df6..f2795af 100644 --- a/setup.py +++ b/setup.py @@ -11,8 +11,8 @@ ], "lint": [ "black>=22.3.0,<23.0", # auto-formatter and linter - "mypy>=0.910,<1.0", # Static type analyzer - "flake8>=3.8.3,<4.0", # Style linter + "mypy>=0.961,<1.0", # Static type analyzer + "flake8>=4.0.1,<5.0", # Style linter "isort>=5.10.1,<6.0", # Import sorting linter ], "release": [ # `release` GitHub Action job uses this @@ -22,7 +22,7 @@ ], "dev": [ "commitizen", # Manage commits and publishing releases - "pre-commit", # Ensure that linters are run prior to commiting + "pre-commit", # Ensure that linters are run prior to committing "pytest-watch", # `ptw` test watcher/runner "IPython", # Console for interacting "ipdb", # Debugger (Must use `export PYTHONBREAKPOINT=ipdb.set_trace`) @@ -54,8 +54,8 @@ include_package_data=True, install_requires=[ "importlib-metadata ; python_version<'3.8'", - "eth-ape>=0.2.1,<0.3.0", - ], # NOTE: Add 3rd party libraries here + "eth-ape>=0.3.0,<0.4.0", + ], python_requires=">=3.7.2,<3.11", extras_require=extras_require, py_modules=["ape_bsc"], diff --git a/tests/.gitkeep b/tests/__init__.py similarity index 100% rename from tests/.gitkeep rename to tests/__init__.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..8a1abde --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,13 @@ +import pytest +from ape._cli import cli as ape_cli +from click.testing import CliRunner + + +@pytest.fixture +def runner(): + return CliRunner() + + +@pytest.fixture +def cli(): + return ape_cli diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..8ae51dc --- /dev/null +++ b/tests/test_integration.py @@ -0,0 +1,33 @@ +EXPECTED_OUTPUT = """ +arbitrum +├── mainnet +│ ├── alchemy +│ └── geth (default) +├── testnet +│ ├── alchemy (default) +│ └── geth +└── local (default) + └── test (default) +""".strip() + + +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. + """ + actual = f"arbitrum{actual.split('arbitrum')[-1]}" + 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 + + +def test_networks(runner, cli): + result = runner.invoke(cli, ["networks", "list"]) + assert_rich_text(result.output, EXPECTED_OUTPUT)