Skip to content

Hide mutants shadowed by a surviving code-removing mutant in browse - #628

Open
aliassar wants to merge 1 commit into
boxed:mainfrom
aliassar:shadowed-mutants
Open

aliassar wants to merge 1 commit into
boxed:mainfrom
aliassar:shadowed-mutants

Conversation

@aliassar

@aliassar aliassar commented Nov 5, 2026

Copy link
Copy Markdown

Part 1 of #367: mutmut browse now hides mutants that are shadowed by a surviving mutant that removes their code, and s shows them again. mutmut has no line-deletion operator, so the shadowing mutants are the ones that already remove code: x = foo() -> x = None, an argument set to None or dropped, a lambda body set to None, and a dropped case. Replacing a plain name or literal doesn't count. Each mutant's source span, plus the removed span for those operators, now goes in the .meta file, and a mutant inside code removed by a survivor is shadowed by the outermost one. On a small project browse went from 9 survivors to 1 (note = None), and s shows the other 8. A mutants/ dir from an older version has no spans, so nothing is hidden until the source file changes or mutants/ is deleted. Skipping runs (part 2) is left for later.

Part of #367

If `x = foo(a + 1)` -> `x = None` survives, the mutants inside
`foo(a + 1)` are noise: whatever test kills the first one will most
likely kill them too.

Mutation generation now records the source span of each mutant in the
.meta file, plus the span of the code removed by mutants of the
assignment, argument removal, lambda and match operators. Replacing a
plain name or literal, like `x = False` -> `x = None`, does not count as
removing code, as such mutants often survive and would hide the
`False` -> `True` flip. When results are loaded, a mutant whose span
lies inside the code removed by a surviving mutant is shadowed by it.
`mutmut browse` hides shadowed mutants and the `s` key shows them again.

Part of boxed#367

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant