Skip to content

Commit 70677e3

Browse files
committed
chore: migrate to ruff, composite action, uv
1 parent 951e539 commit 70677e3

3 files changed

Lines changed: 17 additions & 68 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
name: build
22

33
on:
4-
push:
5-
paths:
6-
- '.github/workflows/build.yml'
7-
- '**/*.py'
8-
branches:
9-
- '**'
10-
tags:
11-
- '!**'
12-
pull_request:
13-
paths:
14-
- '.github/workflows/build.yml'
15-
- '**/*.py'
4+
push: ~
5+
pull_request: ~
166
workflow_dispatch: ~
177

188
jobs:
199
lint:
2010
runs-on: ubuntu-latest
2111
steps:
22-
- uses: actions/checkout@v5
23-
- uses: extractions/setup-just@v3
24-
- uses: actions/setup-python@v6
12+
- uses: justintime50/composite-actions/bootstrap-python@v1
2513
with:
2614
python-version: '3.14'
2715
- run: just install lint
@@ -31,19 +19,15 @@ jobs:
3119
matrix:
3220
pythonversion: ['3.10', '3.11', '3.12', '3.13', '3.14']
3321
steps:
34-
- uses: actions/checkout@v5
35-
- uses: extractions/setup-just@v3
36-
- uses: actions/setup-python@v6
22+
- uses: justintime50/composite-actions/bootstrap-python@v1
3723
with:
3824
python-version: ${{ matrix.pythonversion }}
3925
- run: just install coverage
4026
coverage:
4127
if: github.ref == 'refs/heads/main'
4228
runs-on: ubuntu-latest
4329
steps:
44-
- uses: actions/checkout@v5
45-
- uses: extractions/setup-just@v3
46-
- uses: actions/setup-python@v6
30+
- uses: justintime50/composite-actions/bootstrap-python@v1
4731
with:
4832
python-version: '3.14'
4933
- run: just install coverage

justfile

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
PYTHON_BINARY := "python3"
2-
VIRTUAL_ENV := "venv"
1+
VIRTUAL_ENV := ".venv"
32
VIRTUAL_BIN := VIRTUAL_ENV / "bin"
43
PROJECT_NAME := "algorithms"
54
TEST_DIR := "test"
@@ -8,14 +7,6 @@ TEST_DIR := "test"
87
bandit:
98
{{VIRTUAL_BIN}}/bandit -r {{PROJECT_NAME}}/
109

11-
# Runs the Black Python formatter against the project
12-
black:
13-
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/
14-
15-
# Checks if the project is formatted correctly against the Black rules
16-
black-check:
17-
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check
18-
1910
# Test the project and generate an HTML coverage report
2011
coverage:
2112
{{VIRTUAL_BIN}}/pytest --cov={{PROJECT_NAME}} --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=75
@@ -25,28 +16,20 @@ clean:
2516
rm -rf {{VIRTUAL_ENV}} dist *.egg-info .coverage htmlcov .*cache
2617
find . -name '*.pyc' -delete
2718

28-
# Run flake8 checks against the project
29-
flake8:
30-
{{VIRTUAL_BIN}}/flake8 {{PROJECT_NAME}}/ {{TEST_DIR}}/
31-
3219
# Lints the project
33-
lint: black-check isort-check flake8 mypy bandit
20+
lint:
21+
{{VIRTUAL_BIN}}/ruff check {{PROJECT_NAME}}/ {{TEST_DIR}}/
22+
{{VIRTUAL_BIN}}/ruff format --check {{PROJECT_NAME}}/ {{TEST_DIR}}/
3423

35-
# Runs all formatting tools against the project
36-
lint-fix: black isort
24+
# Fixes lint issues
25+
lint-fix:
26+
{{VIRTUAL_BIN}}/ruff check --fix {{PROJECT_NAME}}/ {{TEST_DIR}}/
27+
{{VIRTUAL_BIN}}/ruff format {{PROJECT_NAME}}/ {{TEST_DIR}}/
3728

3829
# Install the project locally
3930
install:
40-
{{PYTHON_BINARY}} -m venv {{VIRTUAL_ENV}}
41-
{{VIRTUAL_BIN}}/pip install -e ."[dev]"
42-
43-
# Sorts imports throughout the project
44-
isort:
45-
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/
46-
47-
# Checks that imports throughout the project are sorted correctly
48-
isort-check:
49-
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check-only
31+
uv venv
32+
uv pip install -e '.[dev]'
5033

5134
# Run mypy type checking on the project
5235
mypy:

pyproject.toml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ authors = [{ name = "Justintime50" }]
1313
urls = { Homepage = "http://github.com/justintime50/algorithms" }
1414
optional-dependencies = { dev = [
1515
"bandit == 1.9.*",
16-
"black == 25.*",
17-
"flake8 == 7.*",
18-
"Flake8-pyproject == 1.2.*",
19-
"isort == 7.*",
2016
"mypy == 1.18.*",
2117
"pytest == 9.*",
2218
"pytest-cov == 7.*",
19+
"ruff == 0.14.*",
2320
] }
2421

2522
[tool.setuptools.packages.find]
@@ -28,23 +25,8 @@ exclude = ["examples", "test"]
2825
[tool.setuptools.package-data]
2926
algorithms = ["py.typed"]
3027

31-
[tool.black]
28+
[tool.ruff]
3229
line-length = 120
3330

34-
[tool.isort]
35-
profile = "black"
36-
line_length = 120
37-
indent = 4
38-
force_grid_wrap = 2
39-
multi_line_output = 3
40-
sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
41-
lines_after_imports = 2
42-
include_trailing_comma = true
43-
use_parentheses = true
44-
4531
[tool.mypy]
4632
disable_error_code = "import-untyped"
47-
48-
[tool.flake8]
49-
max-line-length = 120
50-
extend-ignore = "E203"

0 commit comments

Comments
 (0)