Skip to content

Add option of running stubtest using tox #27618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/mypy-stubtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ jobs:
with:
python-version: 3.9

- name: Install mypy
run: |
pip3 install -r requirements/testing/mypy.txt \
-r requirements/testing/all.txt
pip3 install .

- name: Set up reviewdog
run: |
mkdir -p "$HOME/bin"
Expand All @@ -32,13 +26,16 @@ jobs:
sh -s -- -b "$HOME/bin"
echo "$HOME/bin" >> $GITHUB_PATH

- name: Install tox
run: python -m pip install tox

- name: Run mypy stubtest
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -o pipefail
MPLBACKEND=agg python tools/stubtest.py | \
sed -e "s!$pythonLocation/lib/python3.9/site-packages!lib!g" | \
tox -e stubtest | \
sed -e "s!.tox/stubtest/lib/python3.9/site-packages!lib!g" | \
reviewdog \
-efm '%Eerror: %m' \
-efm '%CStub: in file %f:%l' \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
################
# meson-python working directory
build
.mesonpy*

# meson-python/build frontend dist directory
dist
Expand Down
5 changes: 2 additions & 3 deletions doc/devel/coding_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ We generally use `stub files
the type information for ``colors.py``. A notable exception is ``pyplot.py``,
which is type hinted inline.

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

New modules and files: installation
===================================
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
- sphinxcontrib-svg2pdfconverter>=1.1.0
- pikepdf
# testing
- black<24
- coverage
- flake8>=3.8
- flake8-docstrings>=1.4.0
Expand All @@ -64,4 +65,4 @@ dependencies:
- pytest-xdist
- tornado
- pytz
- black<24
- tox
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py38, py39, py310
envlist = py38, py39, py310, stubtest

[testenv]
changedir = /tmp
Expand All @@ -25,3 +25,12 @@ commands =
deps =
pytest
pytz

[testenv:stubtest]
changedir = {tox_root}
commands =
python tools/stubtest.py
usedevelop = False
deps =
-r requirements/testing/mypy.txt
-r requirements/testing/all.txt