Updated pre-commit template (mypy compatible and default Python specified)#

The following updates have been made to the pre-commit template introduced previously.

pre-commit テンプレート の内容を更新。

Main changes#

  1. Add default_language_version

    By specifying the Python version, you can prevent pre-commit from grabbing an unintended Python version (e.g. 3.13) when building a virtual environment.

    default_language_version:
      python: python3.11
    
  2. mypy pre-commit hook support

    Integrating type checking into pre-commit ensures consistent checking locally/CI.

    Also, the commonly used types-* series is specified in additional_dependencies.

    - repo: https://github.com/pre-commit/mirrors-mypy
      rev: 'v1.10.0'
      hooks:
        - id: mypy
          args: [--install-types]
          additional_dependencies:
            - typing-extensions
            - types-requests
            - types-toml
            - types-PyYAML
            - types-setuptools
            - types-python-dateutil
            - pydantic
            - pydantic-settings
    

Article information

author:

Mr. Takagi

Release date:

2025-07-27