Conversation
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds mypy static type checking to the project's pre-commit hooks to enforce type hints across the codebase. The implementation includes minimal mypy configuration that requires type annotations on all function definitions.
Key changes:
- Added mypy as a pre-commit hook using v1.14.1
- Configured mypy in pyproject.toml with strict typing requirements (
disallow_untyped_defs = true) - Added missing return type annotation to test function
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
.pre-commit-config.yaml |
Added mypy hook configuration for static type checking |
pyproject.toml |
Added mypy configuration section with Python 3.9 target and strict typing rules |
test/test_hello.py |
Added -> None return type annotation to test_hello() function |
README.md |
Updated documentation to reflect mypy enforcement via pre-commit hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Static type checker | ||
| rev: v1.14.1 | ||
| hooks: | ||
| - id: mypy |
There was a problem hiding this comment.
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:
- An
argsparameter with--namespace-packagesand--explicit-package-bases, or - An
additional_dependenciesparameter 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.
| - id: mypy | |
| - id: mypy | |
| args: [--namespace-packages, --explicit-package-bases] |
PR Checklist
Changes
Adds mypy type checking as a pre-commit hook with minimal configuration enforcing typed function definitions.
Configuration in
pyproject.toml:python_version = "3.9"- matches minimum supported versiondisallow_untyped_defs = true- enforces type hints on all functionswarn_return_any = true- warns onAnyreturnswarn_unused_configs = true- validates configPre-commit hook:
pre-commit/mirrors-mypyv1.14.1Code updates:
test_hello()to include-> Nonereturn type annotationOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.