Skip to content

Commit cf21071

Browse files
committed
chore: replace black/isort/flake8 with ruff and add ty + deptry
1 parent 0d53373 commit cf21071

7 files changed

Lines changed: 418 additions & 172 deletions

File tree

‎.coveragerc‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎.isort.cfg‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.pre-commit-config.yaml‎

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,29 @@
1+
# Legacy sphinx config; excluded until it is removed in the docs phase
12
exclude: '^docs/conf.py'
23

34
minimum_pre_commit_version: 3.2.0
45
repos:
5-
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v5.0.0
7-
hooks:
8-
- id: trailing-whitespace
9-
- id: check-added-large-files
10-
- id: check-ast
11-
- id: check-json
12-
- id: check-merge-conflict
13-
- id: check-xml
14-
- id: check-yaml
15-
- id: debug-statements
16-
- id: end-of-file-fixer
17-
- id: requirements-txt-fixer
18-
- id: mixed-line-ending
19-
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v6.0.0
8+
hooks:
9+
- id: trailing-whitespace
10+
- id: check-added-large-files
11+
- id: check-ast
12+
- id: check-case-conflict
13+
- id: check-json
14+
- id: check-merge-conflict
15+
- id: check-toml
16+
- id: check-xml
17+
- id: check-yaml
18+
- id: debug-statements
19+
- id: end-of-file-fixer
20+
- id: mixed-line-ending
21+
args: ['--fix=auto']
2022

21-
# If you want to avoid flake8 errors due to unused vars or imports:
22-
- repo: https://github.com/myint/autoflake
23-
rev: v2.3.1
24-
hooks:
25-
- id: autoflake
26-
args: [
27-
--in-place,
28-
--remove-all-unused-imports,
29-
--remove-unused-variables,
30-
]
31-
32-
- repo: https://github.com/pycqa/isort
33-
rev: 5.13.2
34-
hooks:
35-
- id: isort
36-
37-
- repo: https://github.com/psf/black
38-
rev: 24.10.0
39-
hooks:
40-
- id: black
41-
language_version: python3
42-
43-
## If like to embrace black styles even in the docs:
44-
# - repo: https://github.com/asottile/blacken-docs
45-
# rev: v1.12.0
46-
# hooks:
47-
# - id: blacken-docs
48-
# additional_dependencies: [black]
49-
50-
- repo: https://github.com/PyCQA/flake8
51-
rev: 7.1.1
52-
hooks:
53-
- id: flake8
54-
## You can add flake8 plugins via `additional_dependencies`:
55-
additional_dependencies: [flake8-bugbear]
23+
# ruff replaces autoflake, isort, black and flake8(+bugbear)
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.15.7
26+
hooks:
27+
- id: ruff-check
28+
args: [--exit-non-zero-on-fix]
29+
- id: ruff-format

‎Makefile‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.DEFAULT_GOAL := help
2+
3+
.PHONY: install
4+
install: ## Install the virtual environment and pre-commit hooks
5+
@echo ">> Creating virtual environment using uv"
6+
@uv sync
7+
@uv run pre-commit install
8+
9+
.PHONY: check
10+
check: ## Run code quality tools
11+
@echo ">> Checking lock file consistency with 'pyproject.toml'"
12+
@uv lock --locked
13+
@echo ">> Linting code: Running pre-commit"
14+
@uv run pre-commit run -a
15+
@echo ">> Static type checking: Running ty"
16+
@uv run ty check
17+
@echo ">> Checking for obsolete dependencies: Running deptry"
18+
@uv run deptry src
19+
20+
.PHONY: test
21+
test: ## Test the code with pytest (integration tests excluded, see pyproject.toml)
22+
@echo ">> Testing code: Running pytest"
23+
@uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml
24+
25+
.PHONY: build
26+
build: clean-build ## Build wheel and sdist
27+
@echo ">> Creating wheel and sdist files"
28+
@uv build
29+
30+
.PHONY: clean-build
31+
clean-build: ## Remove build artifacts
32+
@echo ">> Removing build artifacts"
33+
@uv run python -c "import shutil; shutil.rmtree('dist', ignore_errors=True)"
34+
35+
.PHONY: publish
36+
publish: ## Publish a release to PyPI (CI-only via OIDC trusted publishing)
37+
@echo "Publishing happens in CI via OIDC trusted publishing (on-release-main.yml)."
38+
@echo "Push a version tag (v*) to trigger a release."
39+
40+
.PHONY: docs
41+
docs: ## Build and serve the documentation (available after the docs phase)
42+
@echo "Docs are built with zensical from the docs phase onward."
43+
44+
.PHONY: docs-test
45+
docs-test: ## Test if documentation can be built without errors (available after the docs phase)
46+
@echo "Docs are built with zensical from the docs phase onward."
47+
48+
.PHONY: help
49+
help:
50+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

0 commit comments

Comments
 (0)