Skip to content

Commit e5bbe4d

Browse files
committed
Disable cache when producing reports
If the cache is used, coverage information will only be reported for modules that were not in the cache. Fixes #5103
1 parent c555e90 commit e5bbe4d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

mypy/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ def __init__(self, data_dir: str,
505505
self.rechecked_modules = set() # type: Set[str]
506506
self.flush_errors = flush_errors
507507
self.cache_enabled = options.incremental and (
508-
not options.fine_grained_incremental or options.use_fine_grained_cache)
508+
not options.fine_grained_incremental or options.use_fine_grained_cache
509+
) and not reports.reporters
509510
self.fscache = fscache
510511
self.find_module_cache = FindModuleCache(self.search_paths, self.fscache, self.options)
511512
if options.sqlite_cache:

test-data/unit/reports.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,14 @@ class Foo:
357357
@attr.s
358358
class Z(object):
359359
pass
360+
361+
[case testCoverageIgnoresCache]
362+
-- Performs two runs to verify that cached information does not prevent
363+
-- modules from being included in reports.
364+
# cmd: mypy --linecoverage-report report a.py
365+
[file a.py]
366+
empty = False
367+
[out]
368+
[out2]
369+
[outfile report/coverage.json]
370+
{"lines": {"$PWD/a.py": [1]}}

0 commit comments

Comments
 (0)