From 6f9670621e1bcb43c3b89f4854ca8ad7e4580387 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 14 Jul 2026 16:03:18 -0400 Subject: [PATCH] build: migrate from mypy to pyright MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace mypy with pyright as the project's type checker, using strict mode. Changes: 1. **`pyproject.toml`** — Replace `mypy==2.3.0` with `pyright` in `[project.optional-dependencies] lint`. Remove `[tool.mypy]` section and add `[tool.pyright]` with `typeCheckingMode = "strict"` and equivalent excludes. 2. **`.pre-commit-config.yaml`** — Replace the `mirrors-mypy` hook with a pyright pre-commit hook (`RobertCraiworthy/mirrors-pyright` or run via `uv run pyright .`). 3. **`.github/CONTRIBUTING.md`** — Update the "Run type checking" command from `uv run mypy .` to `uv run pyright .`. 4. **`.gitignore`** — Remove mypy-specific entries (`.mypy_cache/`) if present; no pyright cache directory is needed (it uses `node_modules/.pyright` internally, already gitignored by most templates). 5. **Verify** — Run `uv run pyright .` locally to confirm clean output or surface any new errors to address. --- .github/CONTRIBUTING.md | 2 +- .gitignore | 5 ----- .pre-commit-config.yaml | 11 +++++++---- pyproject.toml | 10 +++------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 66abe36..0efcdfc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -113,7 +113,7 @@ uv run ruff format Run type checking: ```sh -uv run mypy . +uv run pyright . ``` ## Build diff --git a/.gitignore b/.gitignore index c967276..2bb1025 100644 --- a/.gitignore +++ b/.gitignore @@ -146,11 +146,6 @@ venv.bak/ # mkdocs documentation /site -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - # Pyre type checker .pyre/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c59c30..d4c1dda 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,8 +22,11 @@ repos: args: [--fix] - id: ruff-format - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.1 + - repo: local hooks: - - id: mypy - entry: bash -c 'uv run mypy .' + - id: pyright + name: pyright + entry: uv run pyright . + language: system + types: [python] + pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index 65df64e..c93b97c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,8 @@ docs = [ "pdoc==16.0.0", ] lint = [ - "mypy==2.3.0", "pre-commit==4.6.0", + "pyright==1.1.411", "ruff==0.15.21", ] test = [ @@ -53,12 +53,8 @@ ignore = [ "E501", # line too long (handled by ruff) ] -[tool.mypy] -strict = true -ignore_missing_imports = true -exclude = [ - '^tests/.*' -] +[tool.pyright] +typeCheckingMode = "strict" [tool.coverage.run] omit = [