Skip to content

Commit 8c6df05

Browse files
committed
🧪 Publish MyPy type coverage to Codecov
1 parent d678135 commit 8c6df05

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

‎.github/workflows/ci.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
216216
# multiple flags is marked as an error in codecov UI, but is actually fine
217217
# https://github.com/codecov/feedback/issues/567
218-
flags: Windows,${{ matrix.python }}
218+
flags: pytest,Windows,${{ matrix.python }}
219219
# this option cannot be set in .codecov.yml
220220
fail_ci_if_error: true
221221

@@ -278,8 +278,18 @@ jobs:
278278
with:
279279
directory: empty
280280
name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
281-
flags: Ubuntu,${{ matrix.python }}
281+
flags: pytest,Ubuntu,${{ matrix.python }}
282282
fail_ci_if_error: true
283+
- if: >-
284+
always()
285+
&& matrix.check_formatting == '1'
286+
uses: codecov/codecov-action@v5
287+
with:
288+
disable_search: true
289+
files: empty/mypy-cov-*-py-*/*
290+
flags: MyPy
291+
fail_ci_if_error: true
292+
name: MyPy type coverage
283293
284294
macOS:
285295
name: 'macOS (${{ matrix.python }})'
@@ -320,7 +330,7 @@ jobs:
320330
with:
321331
directory: empty
322332
name: macOS (${{ matrix.python }})
323-
flags: macOS,${{ matrix.python }}
333+
flags: pytest,macOS,${{ matrix.python }}
324334
fail_ci_if_error: true
325335

326336
# run CI on a musl linux
@@ -356,7 +366,7 @@ jobs:
356366
with:
357367
directory: empty
358368
name: Alpine
359-
flags: Alpine,${{ steps.get-version.outputs.version }}
369+
flags: pytest,Alpine,${{ steps.get-version.outputs.version }}
360370
fail_ci_if_error: true
361371

362372
Cython:
@@ -416,7 +426,7 @@ jobs:
416426
uses: codecov/codecov-action@v5
417427
with:
418428
name: Cython
419-
flags: Cython,${{ steps.get-version.outputs.version }}
429+
flags: pytest,Cython,${{ steps.get-version.outputs.version }}
420430
fail_ci_if_error: true
421431

422432
# https://github.com/marketplace/actions/alls-green#why

‎README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
:target: https://anaconda.org/conda-forge/trio
1919
:alt: Latest conda-forge version
2020

21-
.. image:: https://codecov.io/gh/python-trio/trio/branch/main/graph/badge.svg
22-
:target: https://codecov.io/gh/python-trio/trio
21+
.. image:: https://codecov.io/gh/python-trio/trio/graph/badge.svg?flag=pytest
22+
:target: https://app.codecov.io/gh/python-trio/trio?flags[]=pytest
2323
:alt: Test coverage
2424

2525
Trio – a friendly Python library for async concurrency and I/O

‎check.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ echo "::group::Mypy"
5757
rm -f mypy_annotate.dat
5858
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
5959
set -o pipefail
60-
mypy --show-error-end --python-version=3.13 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
60+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-linux-py-3.13 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
6161
|| { echo "* Mypy (Linux, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6262
# Darwin tests FreeBSD too
63-
mypy --show-error-end --python-version=3.13 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
63+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-macos-py-3.13 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
6464
|| { echo "* Mypy (Mac, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
65-
mypy --show-error-end --python-version=3.13 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
65+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-windows-py-3.13 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
6666
|| { echo "* Mypy (Windows, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
67-
mypy --show-error-end --python-version=3.9 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
67+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-linux-py-3.9 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
6868
|| { echo "* Mypy (Linux, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6969
# Darwin tests FreeBSD too
70-
mypy --show-error-end --python-version=3.9 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
70+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-macos-py-3.9 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
7171
|| { echo "* Mypy (Mac, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
72-
mypy --show-error-end --python-version=3.9 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
72+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-windows-py-3.9 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
7373
|| { echo "* Mypy (Windows, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
7474
set +o pipefail
7575
# Re-display errors using Github's syntax, read out of mypy_annotate.dat

‎test-requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10
1111

1212
# Tools
1313
black; implementation_name == "cpython"
14-
mypy # Would use mypy[faster-cache], but orjson has build issues on pypy
14+
mypy[reports] # Would use mypy[faster-cache], but orjson has build issues on pypy
1515
orjson; implementation_name == "cpython"
1616
ruff >= 0.8.0
1717
astor # code generation

‎test-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jedi==0.19.2 ; implementation_name == 'cpython'
6767
# via -r test-requirements.in
6868
jinja2==3.1.4
6969
# via sphinx
70+
lxml==5.3.0
71+
# via mypy
7072
markupsafe==3.0.2
7173
# via jinja2
7274
mccabe==0.7.0

0 commit comments

Comments
 (0)