Skip to content

Commit 02436f3

Browse files
authored
refactor: 🔧 use Pyrefly rather than mypy for type checking (#313)
1 parent a980ed5 commit 02436f3

9 files changed

Lines changed: 22 additions & 21 deletions

File tree

template/.config/mypy.ini

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

template/.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ repos:
3232
rev: v1.46.2
3333
hooks:
3434
- id: typos
35+
args: [--config, .config/typos.toml, --force-exclude]
3536

3637
- repo: https://github.com/astral-sh/ruff-pre-commit
3738
# Ruff version.
@@ -42,3 +43,13 @@ repos:
4243
args: [--fix]
4344
# Run the formatter.
4445
- id: ruff-format
46+
47+
- repo: https://github.com/facebook/pyrefly-pre-commit
48+
# Note: this is the version of the pre-commit hook, NOT the pyrefly version used for type checking.
49+
rev: 1.2.0.dev1
50+
hooks:
51+
- id: pyrefly-check
52+
name: Pyrefly (type checking)
53+
# Recommended to do full repo checks, not just on changed files.
54+
pass_filenames: false
55+
language: system

template/.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"GitHub.vscode-pull-request-github",
99
"ms-python.python",
1010
"ms-python.vscode-pylance",
11-
"matangover.mypy",
11+
"meta.pyrefly",
1212
"njpwerner.autodocstring",
1313
"quarto.quarto",
1414
"ms-toolsai.jupyter",

template/.vscode/settings.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"files.insertFinalNewline": true,
2929
"python.testing.pytestEnabled": true,
3030
"python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest",
31-
"mypy.runUsingActiveInterpreter": true,
32-
"mypy.configFile": ".config/mypy.ini",
3331
"conventionalCommits.emojiFormat": "emoji",
3432
"conventionalCommits.promptScopes": false,
3533
"typos.config": ".config/typos.toml",

template/CONTRIBUTING.md.jinja

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ It's easiest to install uv and justfile using
2828
install uv and justfile by running:
2929

3030
``` bash
31-
pipx install uv rust-just
31+
pipx install uv rust-just pyrefly
3232
```
3333

3434
We keep all our development workflows in the `justfile`, so you can
@@ -79,19 +79,15 @@ commit.
7979
such as:
8080
- `quartodoc.py`: Custom
8181
[`quartodoc`](https://machow.github.io/quartodoc/) renderer.
82-
- `mypy.ini`: [`mypy`](https://mypy.readthedocs.io/en/stable/)
83-
configuration file for type checking Python code.
8482
- `ruff.toml`: [Ruff](https://docs.astral.sh/ruff/) configuration file
8583
for linting and formatting Python code.
8684
- `rumdl.toml` and `panache.toml`: [rumdl](https://rumdl.dev) and
8785
[Panache](https://panache.bz) configuration file for formatting Markdown
8886
files in the project.
89-
{% if for_seedcase -%}
9087
- `cog.toml`: [Cocogitto](https://docs.cocogitto.io) configuration file
9188
for managing versions.
9289
- `cliff.toml`: [git-cliff](https://git-cliff.org) configuration file for
9390
creating the changelog.
94-
{%- endif %}
9591
- `.copier-answers.yml`: Contains the answers you gave when copying the
9692
package from the template.
9793
**You should not modify this file directly.**

template/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
project.
55
- Run `git init -b main` to create the project as a Git repository.
66
- Install these packages
7-
`uv add --dev pytest genbadge jupyter pytest-cov quartodoc quarto types-tabulate mypy`
7+
`uv add --dev pytest genbadge jupyter pytest-cov quartodoc quarto types-tabulate`
88
- Run `just list-todos` and complete all the TODO items.
99
- Run `just install-precommit` to install the pre-commit hooks.
1010
- Run `just build-readme` to build the Markdown version of the README. {%- if

template/justfile.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ check-python:
7272
# Check formatting
7373
uvx ruff check .
7474
# Check types
75-
uv run mypy --pretty . --config-file .config/mypy.ini
75+
uvx pyrefly check
7676

7777
# Run basic security checks on the package
7878
check-security:

template/pyproject.toml.jinja

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = []
2020
classifiers = [
2121
"License :: OSI Approved :: MIT License",
2222

23-
# Strict typing, checked via mypy
23+
# Strict typing, checked via Pyrefly
2424
"Typing :: Typed",
2525

2626
# How mature is this project? Common values are
@@ -57,5 +57,11 @@ build-backend = "hatchling.build"
5757
# - Trigger failure if below 90% code coverage
5858
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"
5959

60+
[tool.pyrefly]
61+
project-includes = ["src/"]
62+
min-severity = "warn"
63+
python-version = "3.12.0"
64+
preset = "strict"
65+
6066
[tool.ruff]
6167
extend = ".config/ruff.toml"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# ruff: noqa
2-
# mypy: ignore-errors

0 commit comments

Comments
 (0)