python / python/mypy

Allow using Cobertura XML report in incremental mode

Open
#9,041 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature priority-2-low
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

I'm trying to use diff-cover with mypy to enforce any new code to have type annotations. Here's what I use (via tox):

mypy --cobertura-xml-report {envtmpdir} qutebrowser tests {posargs}
diff-cover --fail-under=100 --compare-branch={env:DIFF_BRANCH:origin/{env:GITHUB_BASE_REF:master}} {envtmpdir}/cobertura.xml

That does seem to work fine - however, due to #6076 (cc @mthuurne), it disables incremental mode (causing the runtime of mypy to go up from <1s to ~15s). Note that in my case I don't care about the XML report only containing changed files, because those are the only ones actually relevant for the annotation coverage diff - thus, I think it would be fine to enable the cache for this use-case.

I understand if this is a too specific case, though - I wonder if it'd make sense to have some "enforce annotations for any new code" functionality in mypy itself (perhaps via the incremental mode)?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the mypy entry point for --cobertura-xml-report and the incremental-mode behavior described in issue #6076. Verify the tox example with mypy and diff-cover, and consider the work complete when generating the Cobertura XML report no longer disables incremental mode for this use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.