mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Specify filepath in `cobertura_xml_report`, instead of folder

Open wkoot opened this issue 2 months ago • 3 comments

Feature

Currently, the cobertura_xml_report is used as folder path, in which mypy typically only produces a single file cobertura.xml. I would like to be able to specify a direct output path of the xml file, without having additional folders produced.

Pitch

Using the xml report in a CI requires additional config to archive an extra folder, which is unneeded if a target file can be specified. Even when specifying something like cobertura_xml_report = "mypy.xml", the output file is still mypy.xml/cobertura.xml. A potential workaround --cobertura-xml-report=. is unsafe because mypy simply overwrites any cobertura.xml produced by any other tool.

If the use case is too different from the other reporting outputs which all use DIR, please consider allowing this option via toml config. For instance, something like this:

[tool.mypy]
cobertura_xml_report = {file = "mypy.xml"}
html_report = {dir = "mypy"}

wkoot avatar Nov 12 '25 22:11 wkoot

For the record GitHub Actions makes uploading an artifact from a specific folder quite simple. You don't even have to upload the whole folder!

I think this kind of makes sense as a feature but I'm not sure of its utility. It seems to me any decent CI setup shouldn't care about x.xml vs empty/cobertura.xml... And the potential workaround not working is kiiind of silly. Just rearrange your CI such that cobertura.xml gets uploaded before running any other tools using it.

A5rocks avatar Nov 13 '25 07:11 A5rocks

Running various tools concurrently in separate GitLab CI jobs makes this more complicated. Keeping track of various folders to archive is just some unexpected toil, especially when it's only different for mypy :)

wkoot avatar Nov 13 '25 08:11 wkoot

I'd suggest a simple heuristic: if the provided path ends with .xml, treat it as a filename.

IMO it's more than reasonable to allow specifying a file path instead of an output folder when the tool produces exactly one artifact. (though for CI I personally prefer to put all build/test/check/... artifacts into a separate folder anyway, uploading its tarball at the end)

sterliakov avatar Nov 28 '25 14:11 sterliakov