Add "also_exclude_lines" configuration option · Issue #1391 · nedbat/coveragepy (original) (raw)

When overriding exclude_lines e.g. to exclude pytest.fail or ..., we often include the existing DEFAULT_EXCLUDE pattern (currently \#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)) to maintain the effect of existing "pragma: no cover"s.

This is cumbersome (the regex is large) and doesn't capture the intention, i.e. I have to explain to my team mates what this regex is and where it came from.

Introducing an also_exclude_lines configuration option (alternative name: "additional_exclude_patterns", which might do better to convey that those are regex patterns), that would be appended to the default list, could address that.