Skip to content

Commit 03bb012

Browse files
authored
Merge pull request #2 from abpai/ty
refactor: migrate from pyright to ty as primary type checker
2 parents aa328da + d3f46a4 commit 03bb012

6 files changed

Lines changed: 68 additions & 28 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
hooks:
2323
- id: pytest-check
2424
name: pytest-check
25-
entry: bash -c "PYTHONPATH=. uv run pytest --co -q -m \"not integration\""
25+
entry: bash -c "PYTHONPATH=. uv run pytest --co -q"
2626
language: system
2727
pass_filenames: false
2828
always_run: true

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This document provides coding guidelines for AI agents working on this Python pr
77
- **Tooling**: Use `uv` for all package management
88
- **Python Version**: 3.13+
99
- **Package Manager**: uv (fast, modern dependency management)
10+
- **Type Checker**: ty (Astral's fast type checker, alpha stage) - `make typecheck`
11+
- Note: ty is in early development and may have bugs/missing features
1012

1113
## Code Style
1214

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ lint:
3636
format:
3737
uv run ruff format .
3838

39-
typecheck:
40-
uv run pyright
39+
typecheck: ## Run ty type checker
40+
uv run ty check
4141

4242
test: ## Run Pytest
4343
uv run pytest

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This template is a **lean starting point** for Python projects that use:
77
- ⚙️ Pydantic Settings – typed environment configuration
88
- 📦 uv – fast dependency management / locking
99
- 📝 structlog – structured logging
10+
- 🔍 ty – fast type checking (Rust-powered)
1011

1112
---
1213

@@ -56,7 +57,7 @@ This template is a **lean starting point** for Python projects that use:
5657
| `make setup` | Install dependencies + pre-commit hooks |
5758
| `make format` | Format code with Ruff |
5859
| `make lint` | Run Ruff linter |
59-
| `make typecheck` | Run Pyright type checker |
60+
| `make typecheck` | Run ty type checker |
6061
| `make test` | Run Pytest |
6162
| `make clean` | Remove \*.pyc & cache directories |
6263
| `make lock-check` | Assert `uv.lock` is in sync |
@@ -108,6 +109,21 @@ Includes: PyTorch, scikit-learn, MLflow, matplotlib, numpy, pandas, and seaborn.
108109

109110
---
110111

112+
## Type Checking with ty
113+
114+
This template uses [ty](https://github.com/astral-sh/ty), Astral's fast type checker written in Rust.
115+
116+
**Note:** ty is in alpha and under active development. While production use is not yet recommended, it's suitable for experimentation and early adoption.
117+
118+
```bash
119+
# Run ty type checker
120+
make typecheck
121+
```
122+
123+
Configuration is in `pyproject.toml` under `[tool.ty]`.
124+
125+
---
126+
111127
## License
112128

113129
MIT

pyproject.toml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ dependencies = [
2020
dev = [
2121
"ipykernel>=6.30.1",
2222
"pre-commit>=4.3.0",
23-
"pyright>=1.1.406",
2423
"pytest>=8.4.2",
2524
"pytest-cov>=6.2.1",
2625
"ruff>=0.13.3",
26+
"ty>=0.0.1a21",
2727
]
2828

2929
ml = [
@@ -66,13 +66,23 @@ python_files = ["test_*.py"]
6666
addopts = ["-ra"]
6767
pythonpath = ["."]
6868

69-
[tool.pyright]
70-
include = ["*.py", "tests"]
71-
exclude = ["**/__pycache__"]
72-
typeCheckingMode = "off"
69+
[tool.ty]
70+
# Astral's ty type checker configuration
7371

74-
reportMissingImports = true
75-
reportMissingTypeStubs = false
72+
[tool.ty.environment]
73+
# Point to your project venv; ty auto-detects .venv but this is explicit & robust.
74+
python = ".venv"
75+
python-version = "3.13"
7676

77-
pythonVersion = "3.13"
78-
pythonPlatform = "All"
77+
[tool.ty.src]
78+
include = ["src", "utils", "tests"]
79+
exclude = ["**/__pycache__", "*.pyc"]
80+
respect-ignore-files = true
81+
82+
[tool.ty.rules]
83+
# Strict type checking rules
84+
possibly-unresolved-reference = "error"
85+
division-by-zero = "error"
86+
87+
[tool.ty.terminal]
88+
output-format = "concise"

uv.lock

Lines changed: 27 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)