From b4d4c8835ed369cd7cebd79b963a7edf2e06c84c Mon Sep 17 00:00:00 2001 From: HangenYuu Date: Sun, 19 May 2024 10:45:32 +0800 Subject: [PATCH 1/4] Moved mypy from pre-commit to GitHub Action --- .github/workflows/mypy.yml | 44 ++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 14 ------------ 2 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/mypy.yml diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 0000000000..181821d6f5 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,44 @@ +name: mypy + +on: + pull_request: + push: + branches: [main] + +jobs: + mypy: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v4 + - name: Cache conda + uses: actions/cache@v4 + env: + # Increase this value to reset cache if environment.yml has not changed + CACHE_NUMBER: 0 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-py310-conda-${{ env.CACHE_NUMBER }}-${{ + hashFiles('environment.yml') }} + - uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + mamba-version: "*" + activate-environment: pytensor-test + channel-priority: strict + environment-file: environment.yml + python-version: "3.10" + use-mamba: true + use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + - name: Install-pytensor and mypy dependencies + run: | + conda activate pytensor-test + pip install -e . + python --version + - name: Run mypy + run: | + conda activate pytensor-test + python ./scripts/run_mypy.py --verbose \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e3f04ccd4..68a0becbdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,17 +27,3 @@ repos: - id: ruff args: ["--fix", "--output-format=full"] - id: ruff-format - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 - hooks: - - id: mypy - language: python - entry: python ./scripts/run_mypy.py --verbose - additional_dependencies: - - numpy>=1.20 - - pandas - - types-filelock - - types-setuptools>=67.6.0.8 - always_run: true - require_serial: true - pass_filenames: false From f49995747d4eee29213b6056a5f546329d789ee1 Mon Sep 17 00:00:00 2001 From: HangenYuu Date: Sun, 19 May 2024 14:00:56 +0800 Subject: [PATCH 2/4] Updated environment.yml dependency to run mypy script in GitHub Action --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 0e5d3387af..844f04d48a 100644 --- a/environment.yml +++ b/environment.yml @@ -41,6 +41,7 @@ dependencies: # code style - ruff # developer tools + - pandas # required to run mypy script - pre-commit - packaging - typing_extensions From ab98ac1a15a31c73d2da83373cb8aff9eb06b21a Mon Sep 17 00:00:00 2001 From: HangenYuu Date: Sun, 19 May 2024 14:07:41 +0800 Subject: [PATCH 3/4] Updated environment.yml dependency to run mypy script in GitHub Action --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 844f04d48a..dbb4e5d1ce 100644 --- a/environment.yml +++ b/environment.yml @@ -26,6 +26,7 @@ dependencies: # For testing - coveralls - diff-cover + - mypy - pytest - pytest-cov - pytest-xdist From a6093e6f2e670d6fe8c8d387ec6ef613cf2ae822 Mon Sep 17 00:00:00 2001 From: HangenYuu Date: Sun, 19 May 2024 14:21:41 +0800 Subject: [PATCH 4/4] Add types-filelock and types-setuptools as dependencies in environment.yml --- environment.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environment.yml b/environment.yml index dbb4e5d1ce..a50b9fcb29 100644 --- a/environment.yml +++ b/environment.yml @@ -27,6 +27,8 @@ dependencies: - coveralls - diff-cover - mypy + - types-filelock + - types-setuptools - pytest - pytest-cov - pytest-xdist