Skip to content

Do not package 'coverage annotate' output - #240

Closed
DrAhmetK wants to merge 1 commit into
jquast:masterfrom
DrAhmetK:exclude-coverage-annotate-artifacts
Closed

DrAhmetK wants to merge 1 commit into
jquast:masterfrom
DrAhmetK:exclude-coverage-annotate-artifacts

Conversation

@DrAhmetK

@DrAhmetK DrAhmetK commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

The 0.8.3 wheel and sdist both ship wcwidth/textwrap.py,cover — a 31,107-byte
coverage annotate output file. It's the only comma-containing path in either
artifact, and it isn't an importable module, so it's 31KB of dead weight in
every install.

$ python -c "import zipfile; print([n for n in zipfile.ZipFile('wcwidth-0.8.3-py3-none-any.whl').namelist() if ',' in n])"
['wcwidth/textwrap.py,cover']
$ python -c "import tarfile; print([n for n in tarfile.open('wcwidth-0.8.3.tar.gz').getnames() if ',' in n])"
['wcwidth-0.8.3/wcwidth/textwrap.py,cover']

Its first lines are the coverage annotate gutter:

> """
> Sequence-aware text wrapping functions.

How it gets in

[tool.hatch.build.targets.sdist].include has "/wcwidth/**", and there's no
wheel target section, so the whole package directory is auto-included. Either
way, an untracked file sitting in wcwidth/ is picked up. tox.ini never runs
coverage annotate, so this looks like a leftover from a manual run rather than
anything the build does. .gitignore has .coverage and htmlcov but no
pattern matching *,cover, so such a file sits in a working tree unnoticed.

Secondary effect: RECORD parsing

Because the name contains a comma, its RECORD line is CSV-quoted, unlike every
other line:

wcwidth/textwrap.py,sha256=RkmzLTCLoQ2RAahVHmbCl-EuikrYeMqtv9oRXeqbQfo,29721
"wcwidth/textwrap.py,cover",sha256=3oRcbbuYhKSGDfomMUe1nsLXixNWrooE6M7woHHx4NY,31107

That's valid RFC 4180 / PEP 376 and csv.reader handles it correctly — the
wheel is not malformed.
But an installer that reads RECORD with
line.split(",")[0] instead of a CSV parser gets "wcwidth/textwrap.py — leading
quote included, truncated at the comma — and then fails its own
files-exist check. I hit this on a platform whose Python executor does exactly
that; it aborts with wheel RECORD lists files missing on disk: "wcwidth/textwrap.py. That's a bug in that parser and I'm not asking you to work
around it. It just happens that the stray file is the only thing that triggers
it, so dropping the file fixes the symptom for every such consumer at once.

The change

  • .gitignore: add *,cover.
  • pyproject.toml: a [tool.hatch.build] exclude = ["*,cover"]. Placed at the
    shared level so it covers the wheel as well as the sdist, which avoids adding
    a [tool.hatch.build.targets.wheel] section just for this.
  • tox.ini: the twine_check env already builds both distributions, so it also
    asserts no packaged path contains a comma.

Either of the first two alone is sufficient — hatchling does honor the
repository's own .gitignore. Both are here because the include list is
explicit about what ships, and the comment above it already notes that ignore
rules aren't wholly reliable here.

Verification

Building master with the file restored into wcwidth/ reproduces the release
exactly; the file list of the wheel I get matches the published 0.8.3 wheel
entry for entry.

# on master, with wcwidth/textwrap.py,cover present
$ python -m build && list-paths dist/
sdist wcwidth/textwrap.py,cover
whl   wcwidth/textwrap.py,cover

# on this branch, same file still present in the tree
$ python -m build && list-paths dist/
(no comma-containing paths)

Full before/after diff of the packaged file lists, both distributions:

- sdist wcwidth/textwrap.py,cover
- whl   wcwidth/textwrap.py,cover

Nothing else changes. The wheel goes from 53 to 52 entries; all 30
wcwidth/table_*.py, all 19 table_grapheme_overrides/_known_*, and all 47
.py files are still present in both. The wheel's RECORD goes from one
CSV-quoted line to none.

The guard was checked in both directions with the project's own tooling:

$ tox -e twine_check           # this branch
  twine_check: OK

$ tox -e twine_check           # fix reverted, artifact in tree
packaged path contains a comma: 'wcwidth-0.8.3/wcwidth/textwrap.py,cover', 'wcwidth/textwrap.py,cover'
  twine_check: FAIL code 1

Worth noting twine check --strict passes in both cases — it doesn't look at
packaged paths, so the existing check wouldn't have caught this.

tox -e py314 (1364 passed, 10 skipped) and tox -e lint are green. No Python
source is touched.

Notes

  • Happy to drop the tox.ini part if you'd rather keep twine_check scoped to
    README/metadata rendering, or move it to its own env — the two-line packaging
    fix stands on its own.
  • I didn't add a docs/intro.rst History entry since 0.8.3 is already released
    and there's no unreleased heading; glad to add one under whatever version you
    intend next.

🤖 Generated with Claude Code

The 0.8.3 wheel and sdist both contain wcwidth/textwrap.py,cover, a 31KB
'coverage annotate' file left over in the package directory: the sdist's
"/wcwidth/**" include and the wheel's automatic package discovery both
sweep it up, and .gitignore has no pattern for it.

Add "*,cover" to .gitignore and to a [tool.hatch.build] exclude covering
both targets, and assert in the twine_check env that no packaged path
contains a comma -- this project has no such file, and a comma must be
CSV-quoted in the wheel's RECORD, which trips installers that parse that
file by splitting on commas rather than as CSV.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jquast

jquast commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

I apologize @DrAhmetK for this coverage filename troubling your day, thanks for taking the time to report it. The next release of wcwidth will include your .gitignore change. Changes other than .gitignore are discarded (Claude tends to write too much "defense in depth" or as it prefers to name it, "belt-and-suspenders". I hope it will be less verbose in the future)

this looks like a leftover from a manual run rather than anything the build does

Indeed it is, I build and publish this package on my personal computer, and I also develop and troubleshoot the library there, and often right before release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants