The root cause of my observations in #24307 (which still deserves its own solution IMHO) is coveragepy/coveragepy#1392. Unfortunately, configuring omit alone does not help because this code snipped does not consider it:
|
# load the report and build the json result to return |
|
import coverage |
|
|
|
cov = coverage.Coverage() |
|
cov.load() |
|
file_set: set[str] = cov.get_data().measured_files() |
|
file_coverage_map: dict[str, FileCoverageInfo] = {} |
|
for file in file_set: |
|
analysis = cov.analysis2(file) |
|
lines_executable = {int(line_no) for line_no in analysis[1]} |
|
lines_missed = {int(line_no) for line_no in analysis[3]} |
|
lines_covered = lines_executable - lines_missed |
|
file_info: FileCoverageInfo = { |
|
"lines_covered": list(lines_covered), # list of int |
|
"lines_missed": list(lines_missed), # list of int |
|
} |
|
file_coverage_map[file] = file_info |
cov._check_include_omit_etc being private, the extension cannot really know what to check. So I propose replacing
|
analysis = cov.analysis2(file) |
by
try:
analysis = cov.analysis2(file)
except NoSource:
continue
The root cause of my observations in #24307 (which still deserves its own solution IMHO) is coveragepy/coveragepy#1392. Unfortunately, configuring
omitalone does not help because this code snipped does not consider it:vscode-python/python_files/vscode_pytest/__init__.py
Lines 432 to 448 in e8dd8c0
cov._check_include_omit_etcbeing private, the extension cannot really know what to check. So I propose replacingvscode-python/python_files/vscode_pytest/__init__.py
Line 440 in e8dd8c0
by