From 8b843bd163b719eaced4924de0dbd0ad924e87e7 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Mon, 6 Jul 2026 19:21:04 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=94=A7=20use=20Pyrefly=20rath?= =?UTF-8?q?er=20than=20mypy=20for=20type=20checking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/.config/mypy.ini | 9 --------- template/.pre-commit-config.yaml | 12 +++++++++++- template/.vscode/extensions.json | 2 +- template/.vscode/settings.json | 2 -- template/CONTRIBUTING.md.jinja | 6 +----- template/TODO.md | 4 ++-- template/justfile.jinja | 2 +- template/pyproject.toml.jinja | 8 +++++++- template/tools/vulture-allowlist.py | 1 - 9 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 template/.config/mypy.ini diff --git a/template/.config/mypy.ini b/template/.config/mypy.ini deleted file mode 100644 index f6c48ee..0000000 --- a/template/.config/mypy.ini +++ /dev/null @@ -1,9 +0,0 @@ -[mypy] -python_version = 3.12 -strict = True - -[mypy-quartodoc.*] -ignore_missing_imports = True - -[mypy-tests.*] -disallow_untyped_defs = False diff --git a/template/.pre-commit-config.yaml b/template/.pre-commit-config.yaml index 7e55ae5..669833e 100644 --- a/template/.pre-commit-config.yaml +++ b/template/.pre-commit-config.yaml @@ -31,4 +31,14 @@ repos: - repo: https://github.com/rvben/rumdl-pre-commit rev: v0.1.94 hooks: - - id: rumdl-fmt # Auto-format + - id: rumdl-fmt + + - repo: https://github.com/facebook/pyrefly-pre-commit + # Note: this is the version of the pre-commit hook, NOT the pyrefly version used for type checking. + rev: 1.2.0.dev1 + hooks: + - id: pyrefly-check + name: Pyrefly (type checking) + # Recommended to do full repo checks, not just on changed files. + pass_filenames: false + language: system diff --git a/template/.vscode/extensions.json b/template/.vscode/extensions.json index 18ec7f6..c051a75 100644 --- a/template/.vscode/extensions.json +++ b/template/.vscode/extensions.json @@ -8,7 +8,7 @@ "GitHub.vscode-pull-request-github", "ms-python.python", "ms-python.vscode-pylance", - "matangover.mypy", + "meta.pyrefly", "njpwerner.autodocstring", "quarto.quarto", "ms-toolsai.jupyter", diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index b82679a..36ae6a8 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -34,9 +34,7 @@ "files.insertFinalNewline": true, "python.testing.pytestEnabled": true, "python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest", - "mypy.runUsingActiveInterpreter": true, "ruff.configuration": ".config/ruff.toml", - "mypy.configFile": ".config/mypy.ini", "conventionalCommits.emojiFormat": "emoji", "conventionalCommits.promptScopes": false } diff --git a/template/CONTRIBUTING.md.jinja b/template/CONTRIBUTING.md.jinja index fcede07..b6a9511 100644 --- a/template/CONTRIBUTING.md.jinja +++ b/template/CONTRIBUTING.md.jinja @@ -28,7 +28,7 @@ It's easiest to install uv and justfile using install uv and justfile by running: ``` bash -pipx install uv rust-just +pipx install uv rust-just pyrefly ``` We keep all our development workflows in the `justfile`, so you can @@ -79,18 +79,14 @@ commit. such as: - `quartodoc.py`: Custom [`quartodoc`](https://machow.github.io/quartodoc/) renderer. - - `mypy.ini`: [`mypy`](https://mypy.readthedocs.io/en/stable/) - configuration file for type checking Python code. - `ruff.toml`: [Ruff](https://docs.astral.sh/ruff/) configuration file for linting and formatting Python code. - `rumdl.toml`: [rumdl](https://rumdl.dev/) configuration file for formatting Markdown files so that they are standardized and consistent - {%- if for_seedcase %} - `cog.toml`: [Cocogitto](https://docs.cocogitto.io) configuration file for managing versions. - `cliff.toml`: [git-cliff](https://git-cliff.org) configuration file for creating the changelog. - {%- endif %} - `.copier-answers.yml`: Contains the answers you gave when copying the package from the template. **You should not modify this file directly.** diff --git a/template/TODO.md b/template/TODO.md index ec672b0..43ebcef 100644 --- a/template/TODO.md +++ b/template/TODO.md @@ -4,11 +4,11 @@ after copying the project. - Run `git init -b main` to create the project as a Git repository. - Install these packages - `uv add --dev pytest genbadge jupyter pytest-cov quartodoc quarto types-tabulate mypy` + `uv add --dev pytest genbadge jupyter pytest-cov quartodoc quarto types-tabulate` - Run `just list-todos` and complete all the TODO items. - Run `just install-precommit` to install the pre-commit hooks. - Run `just build-readme` to build the Markdown version of the README. - {%- if for_seedcase -%} + {% if for_seedcase -%} - Run `just update-quarto-theme` to add the Seedcase Quarto extension. - Install the [`spaid`](https://github.com/seedcase-project/spaid) CLI tool and run these setup steps: diff --git a/template/justfile.jinja b/template/justfile.jinja index a1e0d08..a5524bf 100644 --- a/template/justfile.jinja +++ b/template/justfile.jinja @@ -56,7 +56,7 @@ check-python: # Check formatting uvx ruff check . --config .config/ruff.toml # Check types - uv run mypy --pretty . --config-file .config/mypy.ini + uvx pyrefly check # Reformat Python code to match coding style and general structure format-python: diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index f975cc4..de96016 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -20,7 +20,7 @@ dependencies = [] classifiers = [ "License :: OSI Approved :: MIT License", - # Strict typing, checked via mypy + # Strict typing, checked via Pyrefly "Typing :: Typed", # How mature is this project? Common values are @@ -56,3 +56,9 @@ build-backend = "hatchling.build" # - Create the coverage report in XML (for badge), terminal, and HTML # - Trigger failure if below 90% code coverage addopts = "--tb=short --import-mode=importlib --cov=src --no-cov-on-fail --cov-report=term --cov-report=xml --cov-report=html --cov-fail-under=90" + +[tool.pyrefly] +project-includes = ["src/"] +min-severity = "warn" +python-version = "3.12.0" +preset = "strict" diff --git a/template/tools/vulture-allowlist.py b/template/tools/vulture-allowlist.py index 44a7814..d65b8af 100644 --- a/template/tools/vulture-allowlist.py +++ b/template/tools/vulture-allowlist.py @@ -1,2 +1 @@ # ruff: noqa -# mypy: ignore-errors