-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Assume if TYPE_CHECKING: ... else: ...
block is covered
#831
Comments
You can solve this yourself today by adding this to your .coveragerc file:
More details about this setting are here: Advanced exclusion. Since this is something that is configurable by the user, I would rather not change coverage.py to deal with it. |
…e from urxvt to kitty * It doesn't fuck up your terminal colors. * You can use [peek](peek.md) to record your screen. * Easier to extend. feat(pytest#Excluding code from coverage): Exclude the `if TYPE_CHECKING` code from the coverage If you want [other code to be excluded](nedbat/coveragepy#831), for example the statements inside the `if TYPE_CHECKING:` add to your `pyproject.toml`: ```toml [tool.coverage.report] exclude_lines = [ # Have to re-enable the standard pragma 'pragma: no cover', # Type checking can not be tested 'if TYPE_CHECKING:', ] ``` fix(peek): Add note that it works with kitty feat(prompt_toolkit_fullscreen_applications#Pass more than one key): Pass more than one key To map an action to two key presses use `kb.add('g', 'g')`. feat(prompt_toolkit_fullscreen_applications#styles): Add note on how to debug the styles of the components Set the style to `bg:#dc322f` and it will be highlighted in red.
@nedbat - when would you expect code inside |
A few years later, I think you are right that it should be part of the default. If the user wants to measure those lines, they can. |
Can we also add |
@ikonst - I'm not 100% sure that's a good idea, but also as I've painfully discovered, you really mean |
Yeah, obviously in its escaped form. I think the sharp change in coverage would tell you :) |
It can be quite the footgun when your projects are starting from 100% line coverage... |
This is so we can get a more accurate picture of coverage. For more info see: - nedbat/coveragepy#831
This is so we can get a more accurate picture of coverage. For more info see: - nedbat/coveragepy#831
@nedbat Is the |
nedbat/coveragepy#831 (comment) not configurable via codecov.yml: codecov/codecov-python#107 (comment)
nedbat/coveragepy#831 (comment) not configurable via codecov.yml: codecov/codecov-python#107 (comment) Signed-off-by: Matthew Hoffman <[email protected]>
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
This might become the default in the future, see: - nedbat/coveragepy#831
While coveragepy itself seems to recognized the excluded lines as covered, it seems that uploading the reports to codecov.io does show them as not covered in their reporting. If someone spotted a workaround for that, please let me know. |
I think "excluded" is its own status in coveragepy, are you sure it's "covered" and not "excluded"? Or are you just concerned about coverage %? |
if typing.TYPE_CHECKING
blocks are never run but are still counted as needing test coverage.( https://docs.python.org/3.7/library/typing.html#typing.TYPE_CHECKING )
Example
You have to add
# pragma: no_cover
to theif
block here because coverage.py assumes TYPE_CHECKING to be False, and therefore assumes one of the blocks does not have a test case. It would be good if you didn't have to, and blocks requiring TYPE_CHECKING to be True are assumed to not need test cases.The text was updated successfully, but these errors were encountered: