Skip to content

Commit fd332aa

Browse files
authored
Merge pull request #27618 from dstansby/stubtest-tox
Add option of running stubtest using tox
2 parents d0575d4 + 590d477 commit fd332aa

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

.github/workflows/mypy-stubtest.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ jobs:
1818
with:
1919
python-version: 3.9
2020

21-
- name: Install mypy
22-
run: |
23-
pip3 install -r requirements/testing/mypy.txt \
24-
-r requirements/testing/all.txt
25-
pip3 install .
26-
2721
- name: Set up reviewdog
2822
run: |
2923
mkdir -p "$HOME/bin"
@@ -32,13 +26,16 @@ jobs:
3226
sh -s -- -b "$HOME/bin"
3327
echo "$HOME/bin" >> $GITHUB_PATH
3428
29+
- name: Install tox
30+
run: python -m pip install tox
31+
3532
- name: Run mypy stubtest
3633
env:
3734
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3835
run: |
3936
set -o pipefail
40-
MPLBACKEND=agg python tools/stubtest.py | \
41-
sed -e "s!$pythonLocation/lib/python3.9/site-packages!lib!g" | \
37+
tox -e stubtest | \
38+
sed -e "s!.tox/stubtest/lib/python3.9/site-packages!lib!g" | \
4239
reviewdog \
4340
-efm '%Eerror: %m' \
4441
-efm '%CStub: in file %f:%l' \

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
################
3232
# meson-python working directory
3333
build
34+
.mesonpy*
3435

3536
# meson-python/build frontend dist directory
3637
dist

doc/devel/coding_guide.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ We generally use `stub files
8888
the type information for ``colors.py``. A notable exception is ``pyplot.py``,
8989
which is type hinted inline.
9090

91-
Type hints are checked by the mypy :ref:`pre-commit hook <pre-commit-hooks>`
92-
and can often be verified using ``tools\stubtest.py`` and occasionally may
93-
require the use of ``tools\check_typehints.py``.
91+
Type hints are checked by the mypy :ref:`pre-commit hook <pre-commit-hooks>`,
92+
can often be verified by running ``tox -e stubtest``.
9493

9594
New modules and files: installation
9695
===================================

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies:
4646
- sphinxcontrib-svg2pdfconverter>=1.1.0
4747
- pikepdf
4848
# testing
49+
- black<24
4950
- coverage
5051
- flake8>=3.8
5152
- flake8-docstrings>=1.4.0
@@ -64,4 +65,4 @@ dependencies:
6465
- pytest-xdist
6566
- tornado
6667
- pytz
67-
- black<24
68+
- tox

tox.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py38, py39, py310
7+
envlist = py38, py39, py310, stubtest
88

99
[testenv]
1010
changedir = /tmp
@@ -25,3 +25,12 @@ commands =
2525
deps =
2626
pytest
2727
pytz
28+
29+
[testenv:stubtest]
30+
changedir = {tox_root}
31+
commands =
32+
python tools/stubtest.py
33+
usedevelop = False
34+
deps =
35+
-r requirements/testing/mypy.txt
36+
-r requirements/testing/all.txt

0 commit comments

Comments
 (0)