Skip to content

Add "also_exclude_lines" configuration option #1391

Closed
@ikonst

Description

@ikonst

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.

Activity

nedbat

nedbat commented on Oct 20, 2022

@nedbat
Owner

I like this idea, but I'm not sure when I'll be able to get to it. And I'm not sure what a good name would be. The choices all seem a bit clunky.

added
good firstThis could be a good first contribution
and removed on Oct 20, 2022
ikonst

ikonst commented on Oct 20, 2022

@ikonst
Author

Maybe following the example of flake8's extend_ignore?

nedbat

nedbat commented on Feb 22, 2023

@nedbat
Owner

This is implemented as exclude_also in commit 2a0e7bc.

added and removed
good firstThis could be a good first contribution
on Feb 22, 2023
added a commit that references this issue on Mar 4, 2023
added a commit that references this issue on Mar 12, 2023
added a commit that references this issue on May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nedbat@ikonst

        Issue actions

          Add "also_exclude_lines" configuration option · Issue #1391 · nedbat/coveragepy