@@ -222,15 +222,6 @@ async def run_mypy(
222222 if not line .startswith (str (typeshed_dir / "stubs" ))
223223 )
224224
225- # Redact "note" lines which contain base_dir
226- # Avoids noisy diffs when e.g., mypy points to a stub definition
227- base_dir_re = (
228- f"({ re .escape (str (ctx .get ().base_dir ))} "
229- f"|{ re .escape (str (ctx .get ().base_dir .resolve ()))} )"
230- ".*: note:"
231- )
232- output = re .sub (base_dir_re , "note:" , output )
233-
234225 # Avoids some noise in tracebacks
235226 if "error: INTERNAL ERROR" in output :
236227 output = re .sub ('File ".*/mypy' , 'File "' , output )
@@ -524,6 +515,21 @@ def _get_diff(self) -> str:
524515 old_output = self .old_result .output
525516 new_output = self .new_result .output
526517
518+ # Redact lines which contain essentially "{base_dir}.*" before a colon
519+ # Avoids noisy diffs when e.g. a type checker points to a stub definition
520+ base_dir_re = (
521+ r"^(?P<header>[^:]*?)"
522+ f"(?:{ re .escape (str (ctx .get ().base_dir .resolve ()))} "
523+ f"|{ re .escape (str (ctx .get ().base_dir ))} )"
524+ "[^:]*(?P<trailer>(:|$))"
525+ )
526+ old_output = re .sub (
527+ base_dir_re , r"\g<header>...\g<trailer>" , old_output , flags = re .MULTILINE
528+ )
529+ new_output = re .sub (
530+ base_dir_re , r"\g<header>...\g<trailer>" , new_output , flags = re .MULTILINE
531+ )
532+
527533 old_lines = old_output .splitlines ()
528534 new_lines = new_output .splitlines ()
529535
0 commit comments