Skip to content

Commit 863efc0

Browse files
authored
Moved mypy from pre-commit to GitHub Action (#775)
1 parent 880a57a commit 863efc0

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

.github/workflows/mypy.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: mypy
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
mypy:
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
shell: bash -l {0}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Cache conda
17+
uses: actions/cache@v4
18+
env:
19+
# Increase this value to reset cache if environment.yml has not changed
20+
CACHE_NUMBER: 0
21+
with:
22+
path: ~/conda_pkgs_dir
23+
key: ${{ runner.os }}-py310-conda-${{ env.CACHE_NUMBER }}-${{
24+
hashFiles('environment.yml') }}
25+
- uses: conda-incubator/setup-miniconda@v3
26+
with:
27+
miniforge-variant: Mambaforge
28+
miniforge-version: latest
29+
mamba-version: "*"
30+
activate-environment: pytensor-test
31+
channel-priority: strict
32+
environment-file: environment.yml
33+
python-version: "3.10"
34+
use-mamba: true
35+
use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267
36+
- name: Install-pytensor and mypy dependencies
37+
run: |
38+
conda activate pytensor-test
39+
pip install -e .
40+
python --version
41+
- name: Run mypy
42+
run: |
43+
conda activate pytensor-test
44+
python ./scripts/run_mypy.py --verbose

.pre-commit-config.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,3 @@ repos:
2727
- id: ruff
2828
args: ["--fix", "--output-format=full"]
2929
- id: ruff-format
30-
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.10.0
32-
hooks:
33-
- id: mypy
34-
language: python
35-
entry: python ./scripts/run_mypy.py --verbose
36-
additional_dependencies:
37-
- numpy>=1.20
38-
- pandas
39-
- types-filelock
40-
- types-setuptools>=67.6.0.8
41-
always_run: true
42-
require_serial: true
43-
pass_filenames: false

environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ dependencies:
2626
# For testing
2727
- coveralls
2828
- diff-cover
29+
- mypy
30+
- types-filelock
31+
- types-setuptools
2932
- pytest
3033
- pytest-cov
3134
- pytest-xdist
@@ -41,6 +44,7 @@ dependencies:
4144
# code style
4245
- ruff
4346
# developer tools
47+
- pandas # required to run mypy script
4448
- pre-commit
4549
- packaging
4650
- typing_extensions

0 commit comments

Comments
 (0)