File tree 5 files changed +103
-2
lines changed 5 files changed +103
-2
lines changed Original file line number Diff line number Diff line change
1
+ name : Run MyPy
2
+
3
+ # Mypy is too slow to run as part of regular CI. The purpose of the jobs in
4
+ # this file is to cover running Mypy across:
5
+ #
6
+ # - OSes: Linux, Windows and macOS
7
+ # - Python versions: lowest/highest supported versions, and an intermediate one
8
+ #
9
+ # The build matrix aims for sparse coverage across those two dimensions.
10
+ # Use of BLAS/LAPACK and
8000
SIMD is disabled on purpose, because those things
11
+ # don't matter for static typing and this speeds up the builds.
12
+ #
13
+ # This is a separate job file so it's easy to trigger by hand.
14
+
15
+ on :
16
+ pull_request :
17
+ branches :
18
+ - main
19
+ - maintenance/**
20
+ paths-ignore :
21
+ - ' benchmarks/'
22
+ - ' .circlecl/'
23
+ - ' docs/'
24
+ - ' meson_cpu/'
25
+ - ' tools/'
26
+ workflow_dispatch :
27
+
28
+ defaults :
29
+ run :
30
+ shell : bash
31
+
32
+ concurrency :
33
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
34
+ cancel-in-progress : true
35
+
36
+ permissions :
37
+ contents : read # to fetch code (actions/checkout)
38
+
39
+ jobs :
40
+ mypy :
41
+ if : " github.repository == 'numpy/numpy'"
42
+ name : " MyPy"
43
+ runs-on : ${{ matrix.os_python[0] }}
44
+ strategy :
45
+ matrix :
46
+ os_python :
47
+ - [ubuntu-latest, '3.10'] # switch to 3.12-dev after mypy is upgraded (see gh-23764)
48
+ - [windows-2019, '3.11']
49
+ - [macos-12, '3.9']
50
+ steps :
51
+ - uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
52
+ with :
53
+ submodules : recursive
54
+ fetch-depth : 0
55
+ - uses : actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
56
+ with :
57
+ python-version : ${{ matrix.os_python[1] }}
58
+ - name : Install dependencies
59
+ run : |
60
+ pip install -r build_requirements.txt
61
+ pip install -r test_requirements.txt
62
+ - name : Build
63
+ run : |
64
+ spin build -j2 -- -Dallow-noblas=true -Ddisable-optimization=true --vsenv
65
+ - name : Run Mypy
66
+ run : |
67
+ spin mypy
Original file line number Diff line number Diff line change @@ -925,3 +925,16 @@ def run(ctx, args):
925
925
"""
926
926
ctx .invoke (build )
927
927
ctx .forward (meson_run )
928
+
929
+
930
+ @click .command (context_settings = {"ignore_unknown_options" : True })
931
+ @click .pass_context
932
+ def mypy (ctx ):
933
+ """Run Mypy tests for NumPy
934
+ """
935
+ env = os .environ
936
+ env ['NPY_RUN_MYPY_IN_TESTSUITE' ] = '1'
937
+ ctx .params ['pytest_args' ] = [os .path .join ('numpy' , 'typing' )]
938
+ ctx .params ['markexpr' ] = 'full'
939
+ ctx .forward (test )
940
+
Original file line number Diff line number Diff line change 18
18
_C_INTP ,
19
19
)
20
20
21
+
22
+ # Only trigger a full `mypy` run if this environment variable is set
23
+ # Note that these tests tend to take over a minute even on a macOS M1 CPU,
24
+ # and more than that in CI.
67E6
div>
25
+ RUN_MYPY = "NPY_RUN_MYPY_IN_TESTSUITE" in os .environ
26
+ if RUN_MYPY and RUN_MYPY not in ('0' , '' , 'false' ):
27
+ RUN_MYPY = True
28
+
29
+ # Skips all functions in this file
30
+ pytestmark = pytest .mark .skipif (
31
+ not RUN_MYPY ,
32
+ reason = "`NPY_RUN_MYPY_IN_TESTSUITE` not set"
33
+ )
34
+
35
+
21
36
try :
22
37
from mypy import api
23
38
except ImportError :
Original file line number Diff line number Diff line change @@ -194,7 +194,11 @@ repair-wheel-command = "bash ./tools/wheels/repair_windows.sh {wheel} {dest_dir}
194
194
package = ' numpy'
195
195
196
196
[tool .spin .commands ]
197
- "Build" = [" .spin/cmds.py:build" , " .spin/cmds.py:test" ]
197
+ "Build" = [
198
+ " .spin/cmds.py:build" ,
199
+ " .spin/cmds.py:test" ,
200
+ " .spin/cmds.py:mypy" ,
201
+ ]
198
202
"Environments" = [
199
203
" .spin/cmds.py:run" , " .spin/cmds.py:ipython" ,
200
204
" .spin/cmds.py:python" , " .spin/cmds.py:gdb"
Original file line number Diff line number Diff line change 26
26
# Set available memory value to avoid OOM problems on aarch64.
27
27
# See gh-22418.
28
28
export NPY_AVAILABLE_MEM=" 4 GB"
29
- python -c " import sys; import numpy; sys.exit(not numpy.test(label='full'))"
29
+ # Run full tests with -n=auto. This makes pytest-xdist distribute tests across
30
+ # the available N CPU cores: 2 by default for Linux instances and 4 for macOS arm64
31
+ python -c " import sys; import numpy; sys.exit(not numpy.test(label='full', extra_argv=['-n=auto']))"
30
32
python $PROJECT_DIR /tools/wheels/check_license.py
You can’t perform that action at this time.
0 commit comments