Skip to content

Commit 0ca2cb6

Browse files
committed
Add type-checking infrastructure
Run mypy during pre-commit. For now, only type-check setup.py and _version.py. We will support type checking on Python >= 3.10. 3.9 has too many limitations to be worth supporting. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 013a325 commit 0ca2cb6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ repos:
5353
name: Lint python code with flake8
5454
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
5555

56+
- repo: https://github.com/pre-commit/mirrors-mypy
57+
rev: v1.11.2
58+
hooks:
59+
- id: mypy
60+
name: Check Python types
61+
additional_dependencies: [types-setuptools]
62+
exclude: "^(doc/.*|openslide/(__init__|deepzoom|lowlevel)\\.py|tests/.*|examples/deepzoom/.*)$"
63+
5664
- repo: https://github.com/rstcheck/rstcheck
5765
rev: v6.2.4
5866
hooks:

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ extend-ignore = ["E203", "E741"]
5757
profile = "black"
5858
force_sort_within_sections = true
5959

60+
[tool.mypy]
61+
python_version = "3.10"
62+
strict = true
63+
# temporary, while we bootstrap type checking
64+
follow_imports = "silent"
65+
6066
[tool.pytest.ini_options]
6167
minversion = "7.0"
6268
# don't try to import openslide from the source directory, since it doesn't

0 commit comments

Comments
 (0)