Skip to content

Commit f7c8df9

Browse files
committed
refactor: modernize python tooling
1 parent cb0de67 commit f7c8df9

13 files changed

Lines changed: 208 additions & 249 deletions

.github/workflows/commitlint.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ name: Commit Message
77
jobs:
88
check:
99
runs-on: ubuntu-latest
10+
1011
steps:
11-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v6
1213
with:
1314
fetch-depth: 0
1415

15-
- name: Setup Python
16-
uses: actions/setup-python@v5
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v7
1718
with:
1819
python-version: "3.10"
1920

20-
- name: Install Dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install commitizen
24-
2521
- name: Check commit history
26-
run: cz check --rev-range $(git rev-list --all --reverse | head -1)..HEAD
22+
run: uvx commitizen check --rev-range HEAD~1..HEAD

.github/workflows/prtitle.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ on:
88
- synchronize
99

1010
jobs:
11-
check:
12-
runs-on: ubuntu-latest
11+
check:
12+
runs-on: ubuntu-latest
1313

14-
steps:
15-
- uses: actions/checkout@v4
14+
steps:
15+
- uses: astral-sh/setup-uv@v7
1616

17-
- name: Setup Python
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: "3.10"
21-
22-
- name: Install Dependencies
23-
run: pip install commitizen
24-
25-
- name: Check PR Title
26-
env:
27-
TITLE: ${{ github.event.pull_request.title }}
28-
run: cz check --message "$TITLE"
17+
- name: Check PR Title
18+
run: uvx commitlint "${{ github.event.pull_request.title }}"

.github/workflows/publish.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414

15-
- name: Set up Python
16-
uses: actions/setup-python@v5
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v7
1717
with:
1818
python-version: "3.10"
1919

20-
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install -e .[release]
24-
2520
- name: Build
26-
run: python setup.py sdist bdist_wheel
21+
run: uv build
2722

28-
- name: Publish
29-
env:
30-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
31-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32-
run: twine upload dist/* --verbose
23+
- name: Publish to PyPI
24+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yaml

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,90 +14,60 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

19-
- name: Setup Python
20-
uses: actions/setup-python@v5
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v7
2121
with:
2222
python-version: "3.10"
2323

2424
- name: Install Dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install .[lint]
25+
run: uv sync --group lint
2826

29-
- name: Run Black
30-
run: black --check .
27+
- name: Run Ruff Lint
28+
run: uv run ruff check .
3129

32-
- name: Run isort
33-
run: isort --check-only .
34-
35-
- name: Run flake8
36-
run: flake8 .
30+
- name: Run Ruff Format
31+
run: uv run ruff format --check .
3732

3833
- name: Run mdformat
39-
run: mdformat . --check
34+
run: uv run mdformat --check README.md CONTRIBUTING.md
4035

4136
type-check:
4237
runs-on: ubuntu-latest
4338

4439
steps:
45-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v6
4641

47-
- name: Setup Python
48-
uses: actions/setup-python@v5
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v7
4944
with:
5045
python-version: "3.10"
5146

5247
- name: Install Dependencies
53-
run: |
54-
python -m pip install --upgrade pip
55-
pip install .[lint,test]
48+
run: uv sync --group lint --group test
5649

5750
- name: Run MyPy
58-
run: mypy .
51+
run: uv run mypy .
5952

6053
functional:
6154
runs-on: ${{ matrix.os }}
6255

6356
strategy:
6457
matrix:
65-
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
66-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
67-
58+
os: [ubuntu-latest, macos-latest]
59+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
6860
steps:
69-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v6
7062

71-
- name: Setup Python
72-
uses: actions/setup-python@v5
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v7
7365
with:
7466
python-version: ${{ matrix.python-version }}
7567

7668
- name: Install Dependencies
77-
run: |
78-
python -m pip install --upgrade pip
79-
pip install .[test]
69+
run: uv sync --group test
8070

8171
- name: Run Tests
82-
run: pytest -m "not fuzzing" -n 0 -s --cov
83-
84-
# NOTE: uncomment this block after you've marked tests with @pytest.mark.fuzzing
85-
# fuzzing:
86-
# runs-on: ubuntu-latest
87-
#
88-
# strategy:
89-
# fail-fast: true
90-
#
91-
# steps:
92-
# - uses: actions/checkout@v4
93-
#
94-
# - name: Setup Python
95-
# uses: actions/setup-python@v5
96-
# with:
97-
# python-version: "3.10"
98-
#
99-
# - name: Install Dependencies
100-
# run: pip install .[test]
101-
#
102-
# - name: Run Tests
103-
# run: pytest -m "fuzzing" --no-cov -s
72+
run: uv run ape test -m "not fuzzing" -n 0 -s --cov
73+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,5 @@ version.py
123123
**/.DS_Store
124124
*.swp
125125
*.swo
126+
127+
uv.lock

.pre-commit-config.yaml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,29 @@ repos:
44
hooks:
55
- id: check-yaml
66

7-
- repo: https://github.com/PyCQA/isort
8-
rev: 5.13.2
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.14.14
99
hooks:
10-
- id: isort
11-
12-
- repo: https://github.com/psf/black
13-
rev: 24.10.0
14-
hooks:
15-
- id: black
16-
name: black
17-
18-
- repo: https://github.com/pycqa/flake8
19-
rev: 7.1.1
20-
hooks:
21-
- id: flake8
22-
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]
10+
- id: ruff
11+
args: [--fix]
12+
- id: ruff-format
2313

2414
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.13.0
15+
rev: v1.19.1
2616
hooks:
2717
- id: mypy
28-
additional_dependencies: [types-setuptools, pydantic]
18+
additional_dependencies: [types-setuptools, types-requests, types-PyYAML, pydantic]
2919

3020
- repo: https://github.com/executablebooks/mdformat
31-
rev: 0.7.19
21+
rev: 1.0.0
3222
hooks:
3323
- id: mdformat
3424
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]
3525

26+
- repo: https://github.com/opensource-nepal/commitlint
27+
rev: v1.3.0
28+
hooks:
29+
- id: commitlint
30+
3631
default_language_version:
3732
python: python3

CONTRIBUTING.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,27 @@
33
To get started with working on the codebase, use the following steps prepare your local environment:
44

55
```bash
6-
# Clone the github repo and navigate into the folder
6+
# clone the github repo and navigate into the folder
77
git clone https://github.com/ApeWorX/ape-bsc.git
88
cd ape-bsc
99

10-
# Create and load a virtual environment
11-
python3 -m venv venv
12-
source venv/bin/activate
13-
14-
# Install ape into the virtual environment
15-
python setup.py install
16-
17-
# install the developer dependencies (-e is interactive mode)
18-
pip install -e .'[dev]'
10+
# install the developer dependencies
11+
uv sync --group dev
1912
```
2013

21-
## Pre-Commit Hooks
14+
## Prek Hooks
2215

23-
We use [`pre-commit`](https://pre-commit.com/) hooks to simplify linting and ensure consistent formatting among contributors.
24-
Use of `pre-commit` is not a requirement, but is highly recommended.
16+
We use [`prek`](https://github.com/j178/prek) to run repository hooks and keep contributor workflows
17+
consistent. Use of `prek` is not a requirement, but is highly recommended.
2518

26-
Install `pre-commit` locally from the root folder:
19+
Install hooks locally from the repo root:
2720

2821
```bash
29-
pip install pre-commit
30-
pre-commit install
22+
uv run prek install
3123
```
3224

33-
Committing will now automatically run the local hooks and ensure that your commit passes all lint checks.
25+
Committing will now automatically run the local hooks and ensure that your commit passes all lint
26+
checks.
3427

3528
## Pull Requests
3629

@@ -40,10 +33,11 @@ Pull requests are welcomed! Please adhere to the following:
4033
- Include test cases for any new functionality
4134
- Include any relevant documentation updates
4235

43-
It's a good idea to make pull requests early on.
44-
A pull request represents the start of a discussion, and doesn't necessarily need to be the final, finished submission.
36+
It's a good idea to make pull requests early on. A pull request represents the start of a
37+
discussion, and doesn't necessarily need to be the final, finished submission.
4538

46-
If you are opening a work-in-progress pull request to verify that it passes CI tests, please consider
39+
If you are opening a work-in-progress pull request to verify that it passes CI tests, please
40+
consider
4741
[marking it as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests).
4842

4943
Join the ApeWorX [Discord](https://discord.gg/apeworx) if you have any questions.

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Ecosystem Plugin for Binance Smart Chain support in Ape.
44

55
## Dependencies
66

7-
- [python3](https://www.python.org/downloads) version 3.9 up to 3.12.
7+
- [Python 3](https://www.python.org/downloads) version 3.10 or greater.
88

99
## Installation
1010

@@ -32,14 +32,15 @@ You can install the latest release via [`pip`](https://pypi.org/project/pip/):
3232
pip install ape-bsc
3333
```
3434

35-
### via `setuptools`
35+
### via source
3636

37-
You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:
37+
You can clone the repository and install for development:
3838

3939
```bash
4040
git clone https://github.com/ApeWorX/ape-bsc.git
4141
cd ape-bsc
42-
python3 setup.py install
42+
uv sync --group dev
43+
uv run prek install
4344
```
4445

4546
## Quick Usage

ape_bsc/ecosystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ class BSC(Ethereum):
4141

4242
@property
4343
def config(self) -> BSCConfig: # type: ignore[override]
44-
return cast(BSCConfig, self.config_manager.get_config("bsc"))
44+
return cast("BSCConfig", self.config_manager.get_config("bsc"))

0 commit comments

Comments
 (0)