Skip to content

Commit 2844779

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 2844779

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

mypy/build.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,10 @@ def __init__(self, data_dir: str,
504504
self.stale_modules = set() # type: Set[str]
505505
self.rechecked_modules = set() # type: Set[str]
506506
self.flush_errors = flush_errors
507-
self.cache_enabled = options.incremental and (
508-
not options.fine_grained_incremental or options.use_fine_grained_cache)
507+
self.cache_enabled = (options.incremental
508+
and (not options.fine_grained_incremental
509+
or options.use_fine_grained_cache)
510+
and not reports.reporters)
509511
self.fscache = fscache
510512
self.find_module_cache = FindModuleCache(self.search_paths, self.fscache, self.options)
511513
if options.sqlite_cache:

test-data/unit/reports.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,15 @@ 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 --linecount-report report a.py
365+
[file a.py]
366+
empty = False
367+
[out]
368+
[out2]
369+
[outfile report/linecount.txt]
370+
1 1 0 0 total
371+
1 1 0 0 a

0 commit comments

Comments
 (0)