Skip to content

Commit 34259b3

Browse files
CopilotBorda
andcommitted
Add mypy to pre-commit hooks and configure in pyproject.toml
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
1 parent 808774a commit 34259b3

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ 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
63+
additional_dependencies: []

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ urls."Homepage" = "https://roboflow.com"
2828

2929
[dependency-groups]
3030
dev = [
31+
"mypy",
3132
"pre-commit",
3233
"pytest",
3334
"twine",
@@ -67,3 +68,9 @@ addopts = [
6768
"--color=yes",
6869
"--doctest-modules",
6970
]
71+
72+
[tool.mypy]
73+
python_version = "3.9"
74+
warn_return_any = true
75+
warn_unused_configs = true
76+
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)