Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude_lines unable to exclude entire if block from coverage.py in 5.5 version. #1756

Closed
arbu16 opened this issue Mar 22, 2024 · 6 comments
Closed
Labels
support A support question from a user

Comments

@arbu16
Copy link

arbu16 commented Mar 22, 2024

Have you asked elsewhere?
No
There are other good places to ask for help using coverage.py. These places let
other people suggest solutions, are more likely places for people to find your
question:

I am using exactly same thing as mentioned here #831 (comment) in my .coveragerc file but my report is not as expected showing uncovered for lines inside if block.But when I used pragma: no cover it was able to exclude entire if block but I need if condition: to be excluded in whole repository without using pragma: no cover in from of if block in codebase.

@arbu16 arbu16 added needs triage support A support question from a user labels Mar 22, 2024
@nedbat
Copy link
Owner

nedbat commented Mar 22, 2024

Please provide a link to your code, there must be an error in it somewhere. Can you try using the latest version of coverage? Why are you using 5.5?

@nedbat nedbat added question Further information is requested and removed needs triage labels Mar 22, 2024
@arbu16
Copy link
Author

arbu16 commented Mar 22, 2024

I can upgrade to 7.4.4 latest version so it is that in coverage 5.5 version it cannot exclude entire if block ?
Just FYI: I am exactly using same code ref:#831 (comment).

@nedbat
Copy link
Owner

nedbat commented Mar 23, 2024

It would be easier to help if you could give us a link to your whole repo. Can you at least show us the code that you wanted to exclude, but you weren't able to exclude?

@arbu16
Copy link
Author

arbu16 commented Mar 25, 2024

Hi @nedbat,I did upgrade coverage version from 5.5 to 7.4.4 but still same issue.

Because of privacy concern I will not be able to share link. Below I have reproduced the issue(Pasted the same code)
My .coveragerc file
[run]
concurrency = multiprocessing
parallel = True
[report]
exclude_lines =

pragma: no cover
if TYPE_CHECKING:
if typing.TYPE_CHECKING:

And my coverage for if TYPE_CHECKING: block

if TYPE_CHECKING: --covered

from x import y --uncovered
logging.info("Test Type check ignore for coverage") --uncovered

@nedbat
Copy link
Owner

nedbat commented Mar 25, 2024

Thanks. I hate to nit-pick, but please fix the formatting in the comment, and show the commands you used to run coverage, and show the output of coverage report -m. Thanks.

@nedbat
Copy link
Owner

nedbat commented May 9, 2024

If you get more information, feel free to add it here, and I can re-open the issue.

@nedbat nedbat closed this as completed May 9, 2024
@nedbat nedbat removed the question Further information is requested label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support A support question from a user
Projects
None yet
Development

No branches or pull requests

2 participants