Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ repos:
rev: v2.4.1
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-mypy
# Static type checker
rev: v1.14.1
hooks:
- id: mypy
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mypy pre-commit hook may not work correctly with this project's src/ layout without additional configuration. When mypy runs via pre-commit, it needs to know about the package structure. Consider adding either:

  1. An args parameter with --namespace-packages and --explicit-package-bases, or
  2. An additional_dependencies parameter if the package needs to be installed

For a src/ layout, you typically need to add args: [--namespace-packages, --explicit-package-bases] to ensure mypy can properly resolve imports from the sandbox package.

Suggested change
- id: mypy
- id: mypy
args: [--namespace-packages, --explicit-package-bases]

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ You can run the checks manually on all files:
pre-commit run --all-files
```

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

### Tests 🧪

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ addopts = [
"--color=yes",
"--doctest-modules",
]

[tool.mypy]
python_version = "3.9"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
2 changes: 1 addition & 1 deletion test/test_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sandbox.hello import hello


def test_hello():
def test_hello() -> None:
"""Test the hello function."""
res = hello()
assert res == "World"
Loading