Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

PR Checklist

  • Tests pass
  • Docs if needed
  • pre-commit passes

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 version
  • disallow_untyped_defs = true - enforces type hints on all functions
  • warn_return_any = true - warns on Any returns
  • warn_unused_configs = true - validates config

Pre-commit hook:

  • Uses pre-commit/mirrors-mypy v1.14.1
  • No additional dependencies (template has none currently)

Code updates:

  • Fixed test_hello() to include -> None return type annotation
  • Updated README to reflect mypy is now enforced
Original prompt

This section details on the original issue you should resolve

<issue_title>[Repo] Should we use types and check with mypi?</issue_title>
<issue_description>We can decide if it makes sense for us to force ourself to use types hints and check them with mypi</issue_description>

<agent_instructions>add mypy to precommit as a new hook and add minimal mypy cofig in pyproject.toml</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 8, 2026 17:27
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI changed the title [WIP] Add mypy to precommit with minimal config Add mypy type checking to pre-commit hooks Jan 8, 2026
Copilot AI requested a review from Borda January 8, 2026 17:31
@Borda Borda marked this pull request as ready for review January 8, 2026 17:32
Copilot AI review requested due to automatic review settings January 8, 2026 17:32
@Borda Borda merged commit 3e392d8 into main Jan 8, 2026
8 checks passed
@Borda Borda deleted the copilot/add-mypy-precommit-hook branch January 8, 2026 17:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Repo] Should we use types and check with mypi?

2 participants