Skip to content

Commit

Permalink
Default to pyright, not mypy
Browse files Browse the repository at this point in the history
We can't see any reason to have two type checkers: pyright (part of
pylance) and also mypy. So we've defaulted to "pyright" and removed
"mypy".

This way, if we fix the errors in VSCode, we don't expect to see them
when we run `make types` or `make check`. Also, they should run fine in
Github Actions too.

There's good reasons to use pyright over mypy [1], including:

- Speed. pyright is 3x - 5x faster than mypy when checking large code
  bases. Not that this should be a reason in and of itself.

- Consistency. pyright generally tries to adhere to mypy's behaviour
  unless there is a compelling justification for deviating.

- Ease. pylance includes pyright already in the VS Code extension. So
  not much thinking required to do type checking.

- Dogma. Our main reason is that pyright performs type checking for all code
  regardless of whether it contains type annotations. By default, mypy
  skills all functions or methods that do not have type annotations. We
  believe that type hints are "hints", and should not be enforced. We
  wish to be productive not dogmatic.

[1] https://github.com/microsoft/pyright/blob/main/docs/mypy-comparison.md
  • Loading branch information
webventurer committed Jan 15, 2024
1 parent f980a5c commit 336a6da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ format:

.PHONY: types
types:
mypy .
pyright .

.PHONY: test
test:
Expand Down
2 changes: 0 additions & 2 deletions mypy.ini

This file was deleted.

8 changes: 8 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"reportIncompatibleMethodOverride": "error",
"reportMissingParameterType": "none",
"reportMissingTypeStubs": "none",
"typeCheckingMode": "basic",
"venv": ".venv",
"venvPath": "."
}

0 comments on commit 336a6da

Please sign in to comment.