Skip to content

[BUG] XML generated from coverage.py .coverage doesn’t respect config #648

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

Open
flying-sheep opened this issue Feb 21, 2025 · 0 comments
Assignees
Labels
codecov/codecov-cli enhancement New feature or request Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months

Comments

@flying-sheep
Copy link

flying-sheep commented Feb 21, 2025

Describe the bug
In my project, I configured coverage.py using pyproject.toml to

  • write all files into a test-files folder (idk if that’s relevant)
  • skip coverage for if TYPE_CHECKING: blocks

The reported coverage reflects that (see table below), and when I run coverage xml, the test-files/coverage.xml file is also correct.

Name Stmts Miss Cover ------------------------------------------------------------------ src/fast_array_utils/__init__.py 4 0 100% src/fast_array_utils/_patches.py 2 0 100% src/fast_array_utils/conv/__init__.py 3 0 100% src/fast_array_utils/conv/_asarray.py 25 3 88% src/fast_array_utils/conv/scipy/__init__.py 3 0 100% src/fast_array_utils/conv/scipy/_to_dense.py 12 0 100% src/fast_array_utils/stats/__init__.py 3 0 100% src/fast_array_utils/stats/_sum.py 33 0 100% src/fast_array_utils/types.py 25 2 92%
------------------------------------------------------------------ TOTAL 110 5 95%

But when the codecov CLI runs coverage xml via its coveragepy plugin, the lines are not skipped and codecov reports a 82.87% coverage instead of the expected 95.45% (see codecov report for the linked run below)

See also Additional context below for a workaround I’m using

To Reproduce

  1. set coverage.py’s report.exclude_also setting in a pyproject.toml to ignore some lines
  2. collect coverage in .coverage file and run coverage xml
  3. run codecov CLI’s upload (which will re-generate the XML)
  4. compare the XML you created with the one codecov’s CLI created

Expected behavior
either

  • coverage xml run from the codecov CLI uses the same config as when I run it, or
  • when the file passed via --file already exists, have the codecov CLI skip running coverage xml

Regression
This probably worked using the old coverage PyPI package, but IDK.

Screenshots
NA

Product Area
coverage

Versions

  • OS: linux
  • Git Host: GitHub
  • CI/CD: GitHub Actions
  • Uploader: codecov-action@v5.3.1, codecov-cli@v10.1.0

Commit and CI link
scverse/fast-array-utils@13436951846

https://github.com/scverse/fast-array-utils/actions/runs/13436951846/job/37541444988

Additional context
I can manually work around this by generating the XML myself and then deleting the test-files/.coverage file, but this should be fixed on your side.

See scverse/fast-array-utils#29 for the workaround, which results in the correct coverage of 95.45% being reported.

@flying-sheep flying-sheep added the bug Something isn't working label Feb 21, 2025
@thomasrockhu-codecov thomasrockhu-codecov self-assigned this Feb 26, 2025
@thomasrockhu-codecov thomasrockhu-codecov added enhancement New feature or request Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months and removed bug Something isn't working labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codecov/codecov-cli enhancement New feature or request Medium Medium Priority Issues (to be fixed or re-evaluated in 3 months
Projects
None yet
Development

No branches or pull requests

2 participants