From 0eaf0185253d920353db69036d8a637cba9f688e Mon Sep 17 00:00:00 2001
From: Philipp Stephani
Date: Mon, 18 Aug 2025 09:42:02 +0200
Subject: [PATCH] fix(coverage): Disable certain coverage warnings.
These warnings appear if there are no Python source files in the
instrumented directories,
cf. https://github.com/bazel-contrib/rules_python/issues/2762.
Work towards #2762
---
python/private/python_bootstrap_template.txt | 1 +
python/private/stage2_bootstrap_template.py | 1 +
2 files changed, 2 insertions(+)
diff --git a/python/private/python_bootstrap_template.txt b/python/private/python_bootstrap_template.txt
index 62ded87337..d3afff0214 100644
--- a/python/private/python_bootstrap_template.txt
+++ b/python/private/python_bootstrap_template.txt
@@ -438,6 +438,7 @@ def _RunForCoverage(python_program, main_filename, args, env,
with open(rcfile_name, "w") as rcfile:
rcfile.write('''[run]
relative_files = True
+disable_warnings = module-not-imported, no-data-collected
source =
\t{source}
'''.format(source=source))
diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py
index 689602d3aa..70b48506f4 100644
--- a/python/private/stage2_bootstrap_template.py
+++ b/python/private/stage2_bootstrap_template.py
@@ -321,6 +321,7 @@ def _maybe_collect_coverage(enable):
rcfile.write(
f"""[run]
relative_files = True
+disable_warnings = module-not-imported, no-data-collected
source =
\t{source}
"""