Filter a list of Sphinx warnings to those affecting touched lines.
(
warnings: list[str], ref_a: str, ref_b: str
)
| 156 | |
| 157 | |
| 158 | def 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 | |
| 186 | def annotate_diff( |
no test coverage detected
searching dependent graphs…