Skip to content

Commit 3e392d8

Browse files
CopilotBorda
andauthored
Add mypy type checking to pre-commit hooks (#18)
* Initial plan * Add mypy to pre-commit hooks and configure in pyproject.toml --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Borda <[email protected]>
1 parent c37f9cd commit 3e392d8

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ repos:
5555
rev: v2.4.1
5656
hooks:
5757
- id: codespell
58+
- repo: https://github.com/pre-commit/mirrors-mypy
59+
# Static type checker
60+
rev: v1.14.1
61+
hooks:
62+
- id: mypy

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You can run the checks manually on all files:
4949
pre-commit run --all-files
5050
```
5151

52-
So far, **there is no types checking with mypy**. See [issue](https://github.com/roboflow-ai/template-python/issues/4).
52+
We now use **mypy** for type checking. Type hints are enforced and checked automatically via pre-commit hooks.
5353

5454
### Tests 🧪
5555

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ addopts = [
6767
"--color=yes",
6868
"--doctest-modules",
6969
]
70+
71+
[tool.mypy]
72+
python_version = "3.9"
73+
warn_return_any = true
74+
warn_unused_configs = true
75+
disallow_untyped_defs = true

test/test_hello.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sandbox.hello import hello
44

55

6-
def test_hello():
6+
def test_hello() -> None:
77
"""Test the hello function."""
88
res = hello()
99
assert res == "World"

0 commit comments

Comments
 (0)