From fd0a2f55f85bb8c6e95581cd0193c7222592c47a Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 17 Feb 2023 14:29:12 -0600 Subject: [PATCH] Run mypy checks in test workflow and on push (via pre-commit) - Run mypy on git push (not every commit) but for all files - Running it on pre-commit, doesn't make sense as mypy wants to look at all files, not just diff files - But this is too time consuming to run every commit, so run on push - Update development section documentation on installing, manually running pre-commit for validation that includes running mypy checks --- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 11 ++++++++++- README.md | 8 ++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 676e186b..1d743506 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,7 +50,7 @@ jobs: run: pip install --upgrade .[dev] - name: Validate Application - run: pre-commit + run: pre-commit run --hook-stage manual --all - name: Test Application run: pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 554f241e..77d4ec6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -14,3 +14,12 @@ repos: - id: check-json - id: check-toml - id: check-yaml + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.0.0 + hooks: + - id: mypy + stages: [push, manual] + pass_filenames: false + args: + - --config-file=pyproject.toml diff --git a/README.md b/README.md index 77cfe3fb..a2c8f631 100644 --- a/README.md +++ b/README.md @@ -414,13 +414,13 @@ conda activate khoj ### Validate #### Before Make Changes -1. Install Pre-Commit Validation Hook +1. Install Git Hooks for Validation ```shell - pre-commit install + pre-commit install -t pre-push -t pre-commit ``` - - This ensures standard code formatting fixes and other checks run automatically on every commit + - This ensures standard code formatting fixes and other checks run automatically on every commit and push - Note 1: If [pre-commit](https://pre-commit.com/#intro) didn't already get installed, [install it](https://pre-commit.com/#install) via `pip install pre-commit` - - Note 2: To run the pre-commit changes manually, use `pre-commit run --all` before creating PR + - Note 2: To run the pre-commit changes manually, use `pre-commit run --hook-stage manual --all` before creating PR #### Before Creating PR