Skip to content

Commit 06c6699

Browse files
committed
Test type stubs with stubtest
1 parent 5a26110 commit 06c6699

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: build.sh

+10
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,19 @@ fi
236236

237237
# Tests
238238
if [ "$1" = "test" ]; then
239+
shift
239240
if [ -n "$WHEELDIR" ]; then
240241
$PREFIX/bin/pip install $WHEELDIR/pygit2*-$PYTHON_TAG-*.whl
241242
fi
242243
$PREFIX/bin/pip install -r requirements-test.txt
243244
$PREFIX/bin/pytest --cov=pygit2
244245
fi
246+
247+
# Test .pyi stub file
248+
if [ "$1" = "stubtest" ]; then
249+
shift
250+
$PREFIX/bin/pip install mypy
251+
PYTHONPATH=. $PREFIX/bin/stubtest --mypy-config-file mypy-stubtest.ini pygit2._pygit2
252+
[ $? == 0 ] && echo "stubtest OK"
253+
fi
254+

Diff for: mypy-stubtest.ini

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Config file for testing the stub file (_pygit2.pyi) with "stubtest"
2+
# (tool shipped with mypy).
3+
#
4+
# Run "build.sh stubtest", or:
5+
# stubtest --mypy-config-file test/mypy-stubtest.ini pygit2._pygit2
6+
#
7+
# Format info:
8+
# https://mypy.readthedocs.io/en/stable/config_file.html
9+
10+
[mypy]
11+
warn_unused_configs = True
12+
disallow_any_explicit = True
13+
14+
# don't follow import pygit2 from _pygit2.pyi, we only want to check the pyi file.
15+
[mypy-pygit2]
16+
follow_imports = skip

0 commit comments

Comments
 (0)