Skip to content

wip: don't mutate lines excluded from coverage - #547

Open
nedbat wants to merge 2 commits into
boxed:mainfrom
nedbat:nedbat/excluded-coverage
Open

wip: don't mutate lines excluded from coverage#547
nedbat wants to merge 2 commits into
boxed:mainfrom
nedbat:nedbat/excluded-coverage

Conversation

@nedbat

@nedbat nedbat commented Aug 4, 2026

Copy link
Copy Markdown

Written by Claude. I haven't reviewed it.

@nedbat

nedbat commented Aug 7, 2026

Copy link
Copy Markdown
Author

This now does what I needed it to do. I had code like this:

match something:
    ...

    case _NEVER:
        raise RuntimeError("Not implemented!")

and I have a coverage setting to exclude case _NEVER: clauses. mutmut was mutating those cases by deleting them, and the tests wouldn't fail, because those cases never ran, as expected.

With this pull request, those cases are not mutated, because the coverage analysis is used to understand that they are excluded.

@nedbat
nedbat marked this pull request as ready for review August 7, 2026 15:38
(m for m in mutated_methods if m.line_number_start <= error.line_number <= m.line_number_end), None
)
if mutant is None:
continue

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here to prevent #541 from stopping the run.

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