MCPcopy Index your code
hub / github.com/python/cpython / process_touched_warnings

Function process_touched_warnings

Doc/tools/check-warnings.py:158–183  ·  view source on GitHub ↗

Filter a list of Sphinx warnings to those affecting touched lines.

(
    warnings: list[str], ref_a: str, ref_b: str
)

Source from the content-addressed store, hash-verified

156
157
158def process_touched_warnings(
159 warnings: list[str], ref_a: str, ref_b: str
160) -> list[re.Match[str]]:
161 """Filter a list of Sphinx warnings to those affecting touched lines."""
162 added_files, modified_files = tuple(
163 get_diff_files(ref_a, ref_b, filter_mode=mode) for mode in ("A", "M")
164 )
165
166 warnings_added = filter_and_parse_warnings(warnings, added_files)
167 warnings_modified = filter_and_parse_warnings(warnings, modified_files)
168
169 modified_files_warned = {
170 file
171 for file in modified_files
172 if any(str(file) in warning["file"] for warning in warnings_modified)
173 }
174
175 warnings_modified_touched = [
176 filter_warnings_by_diff(warnings_modified, ref_a, ref_b, file)
177 for file in modified_files_warned
178 ]
179 warnings_touched = warnings_added + list(
180 itertools.chain(*warnings_modified_touched)
181 )
182
183 return warnings_touched
184
185
186def annotate_diff(

Callers 1

annotate_diffFunction · 0.85

Calls 7

get_diff_filesFunction · 0.85
strFunction · 0.85
filter_warnings_by_diffFunction · 0.85
listClass · 0.85
chainMethod · 0.80
anyFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…