Skip to content

Optionally skip empty files in reports #864

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

Merged
merged 1 commit into from
Nov 1, 2019
Merged

Conversation

reybog90
Copy link
Contributor

In a large code base it is fairly common to have many empty __init__.py files. For example in Django applications, you generally end up with files like:
<app>/management/__init__.py
<app>/management/commands/__init__.py
<app>/migrations/__init__.py
<app>/templatetags/__init__.py
<app>/tests/__init__.py
... for each Django app in the project. Most of them are generally empty and pollute the reports.

This change adds a --skip-empty option to skip them in the reports. It follows the same pattern as --skip-covered.

@nedbat
Copy link
Owner

nedbat commented Oct 30, 2019

Since the __init__.py files will be 100% covered, why isn't --skip-covered enough?

@reybog90
Copy link
Contributor Author

Because I like to keep the fully covered files in the report. That makes it easier to see where all the code is and what is the state of each package. It also makes the report more optimistic (assuming the coverage is high).
The empty __init__.py files to me feel out of place in a code coverage report, since there was nothing to cover and many of them are not expected to have any code. In my opinion, the only time it makes sense to show them is when debugging coverage scripts or looking for empty files to delete. At the same time, filtering them out by name won't work, because some of them do contain code.
Since it was very simple to add and I find this option useful, I just went in and made the PR.

@nedbat
Copy link
Owner

nedbat commented Nov 1, 2019

Thanks! Do you have a name I can put into the CONTRIBUTORS file? :)

@nedbat nedbat merged commit 9b11268 into nedbat:master Nov 1, 2019
@reybog90
Copy link
Contributor Author

reybog90 commented Nov 2, 2019

Thanks a lot! You can add "Reya B", if you want :)

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.

2 participants