From c98075bf8bf7ed752470daed431a50d0f199f20a Mon Sep 17 00:00:00 2001 From: Stephan Jaensch Date: Tue, 8 Aug 2017 18:00:24 +0200 Subject: [PATCH 1/2] Add mypy pre-commit hook --- .pre-commit-hooks.yaml | 9 +++++++++ README.md | 3 +++ 2 files changed, 12 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 69e316a..03f04a1 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -191,6 +191,15 @@ # for backward compatibility files: '' minimum_pre_commit_version: 0.15.0 +- id: mypy + name: mypy + description: This hook runs mypy. + entry: mypy + language: python + types: [python] + # for backward compatibility + files: '' + minimum_pre_commit_version: 0.15.0 - id: name-tests-test name: Tests should end in _test.py description: This verifies that test files are named correctly diff --git a/README.md b/README.md index 8113736..4b1a046 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ Add this to your `.pre-commit-config.yaml` - `file-contents-sorter` - Sort the lines in specified files (defaults to alphabetical). You must provide list of target files as input to it. Note that this hook WILL remove blank lines and does NOT respect any comments. - `flake8` - Run flake8 on your python files. - `forbid-new-submodules` - Prevent addition of new git submodules. +- `mypy` - Run mypy on your python files. + - Use `files: ^my_package/.+\.py$` to exclude test and other files from being checked. + - Use `args: ['--config-file', 'mypy-pre-commit.ini']` to use a custom mypy configuration for this pre-commit hook. - `name-tests-test` - Assert that files in tests/ end in `_test.py`. - Use `args: ['--django']` to match `test*.py` instead. - `no-commit-to-branch` - Protect specific branches from direct checkins. From 8518c0a77296122f37cd59bac7b3514ee68b5568 Mon Sep 17 00:00:00 2001 From: Stephan Jaensch Date: Wed, 9 Aug 2017 16:33:24 +0200 Subject: [PATCH 2/2] Add mypy to legacy hooks.yaml too --- hooks.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hooks.yaml b/hooks.yaml index 5278bf5..62bd766 100644 --- a/hooks.yaml +++ b/hooks.yaml @@ -130,6 +130,12 @@ entry: upgrade-your-pre-commit-version files: '' minimum_pre_commit_version: 0.15.0 +- id: mypy + language: system + name: upgrade-your-pre-commit-version + entry: upgrade-your-pre-commit-version + files: '' + minimum_pre_commit_version: 0.15.0 - id: name-tests-test language: system name: upgrade-your-pre-commit-version