Skip to content

Commit 606f480

Browse files
committed
🧪 Publish MyPy type coverage to Codecov
1 parent dcf731e commit 606f480

File tree

6 files changed

+52
-18
lines changed

6 files changed

+52
-18
lines changed

‎.codecov.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ codecov:
66
notify:
77
# This number needs to be changed whenever the number of runs in CI is changed.
88
# Another option is codecov-cli: https://github.com/codecov/codecov-cli#send-notifications
9-
after_n_builds: 31
9+
after_n_builds: 32
1010
wait_for_ci: false
1111
notify_error: true # if uploads fail, replace cov comment with a comment with errors.
1212
require_ci_to_pass: false
@@ -25,9 +25,31 @@ coverage:
2525
round: down
2626
range: 100..100
2727
status:
28-
project:
29-
default:
30-
target: 100%
3128
patch:
3229
default:
3330
target: 100% # require patches to be 100%
31+
lib:
32+
flags:
33+
- pytest
34+
typing:
35+
flags:
36+
- MyPy
37+
project:
38+
default:
39+
target: 100%
40+
lib:
41+
flags:
42+
- pytest
43+
paths:
44+
- src/
45+
target: 100%
46+
tests:
47+
flags:
48+
- pytest
49+
paths:
50+
- tests/
51+
target: 100%
52+
typing:
53+
flags:
54+
- MyPy
55+
target: 91.79%

‎.github/workflows/ci.yml

Lines changed: 15 additions & 5 deletions
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: 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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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)