Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Run linters
run: |
make check-linting
make lint

test:
runs-on: ubuntu-latest
Expand Down
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
# ---------------------------------------------------------------------------
# Lint: Ruff + Black + mypy
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: lint
name: lint
entry: make lint
language: system
pass_filenames: false
stages: [pre-commit]

# ---------------------------------------------------------------------------
# Run tests: fast feedback on commits
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: test
name: test
entry: make test
language: system
pass_filenames: false
stages: [pre-commit]

# ---------------------------------------------------------------------------
# Run documentation tests: fast feedback on commits
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: test-docs
name: test-docs
entry: make test-docs
language: system
pass_filenames: false
stages: [pre-commit]
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ uv --version
Create and sync the virtual environment (including dev dependencies):

```bash
uv sync --all-groups
uv sync --all-groups --all-extras

uv run pre-commit install
```

This will:

- create a local `.venv/`
- install dependencies according to `uv.lock`
- keep the environment reproducible
- setup pre-commit hooks


## Running tests

Expand Down Expand Up @@ -141,13 +145,13 @@ We use:
Run all linters:

```bash
make check-linting
make lint
```

Auto-fix formatting where possible:

```bash
make fix-linting
make lint-fix
```

## Building the package
Expand Down
83 changes: 66 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,81 @@
check-linting:
uv run ruff check typeid/ tests/
uv run black --check --diff typeid/ tests/ --line-length 119
uv run mypy typeid/ --pretty
# ==============================================================================
# Project configuration
# ==============================================================================

PACKAGE := typeid
TESTS := tests
DIST_DIR := dist
VENV_DIR := .venv

fix-linting:
uv run ruff check --fix typeid/ tests/
uv run black typeid/ tests/ --line-length 119
UV := uv run
PYTEST := $(UV) pytest
RUFF := $(UV) ruff
BLACK := $(UV) black
MYPY := $(UV) mypy

# ==============================================================================
# Phony targets
# ==============================================================================

.PHONY: build-sdist
build-sdist:
@rm -rf dist build *.egg-info .venv
@uv build --sdist -o dist
@ls -la dist
.PHONY: help lint lint-fix test test-docs docs docs-build build-sdist clean

# ==============================================================================
# Help
# ==============================================================================

test:
uv run pytest -v
help:
@echo "Available targets:"
@echo ""
@echo " lint Run all linters (ruff, black, mypy)"
@echo " lint-fix Automatically fix linting issues"
@echo " test Run test suite"
@echo " test-docs Run documentation tests"
@echo " docs Serve documentation locally"
@echo " docs-build Build documentation"
@echo " build-sdist Build source distribution"
@echo " clean Remove build artifacts"
@echo ""

# ==============================================================================
# Linting
# ==============================================================================

lint:
$(RUFF) check $(PACKAGE)/ $(TESTS)/
$(BLACK) --check --diff $(PACKAGE)/ $(TESTS)/
$(MYPY) $(PACKAGE)/

lint-fix:
$(RUFF) check --fix $(PACKAGE)/ $(TESTS)/
$(BLACK) $(PACKAGE)/ $(TESTS)/

# ==============================================================================
# Testing
# ==============================================================================

test:
$(PYTEST) -v $(TESTS)

test-docs:
uv run pytest README.md docs/ --markdown-docs
$(PYTEST) README.md docs/ --markdown-docs

# ==============================================================================
# Documentation
# ==============================================================================

docs:
mkdocs serve


docs-build:
docs-build:
mkdocs build

# ==============================================================================
# Build & cleanup
# ==============================================================================

build-sdist: clean
@uv build --sdist -o $(DIST_DIR)
@ls -la $(DIST_DIR)

clean:
@rm -rf $(DIST_DIR) build *.egg-info $(VENV_DIR)
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,19 @@ dev = [
"pytest-markdown-docs>=0.9.0",
"pytest-benchmark>=5.0.1",
"maturin>=1.5; platform_system != 'Windows'",
"pre-commit>=4.5.1",
]

[tool.black]
line-length = 119

[tool.ruff]
line-length = 119
target-version = "py311"

[tool.mypy]
pretty = true

[build-system]
requires = ["maturin>=1.5"]
build-backend = "maturin"
Expand Down
4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

78 changes: 78 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.