econchick / interrogate

Explain yourself! Interrogate a codebase for docstring coverage.
https://interrogate.readthedocs.io
MIT License
562 stars 46 forks source link

`ignore-semiprivate` does not ignore semiprivate modules #146

Open tnytown opened 1 year ago

tnytown commented 1 year ago

Describe the feature you'd like

In sigstore-python, we mark modules as internal / semiprivate by prefixing them with _. I'd like interrogate to consider members of these modules as implicitly semiprivate, just like how interrogate already ignores public members of semiprivate classes.

Here's a minimal example:

_test.py ```py # semiprivate class class _Foo(): # public member def bar(): pass # public class class Foo(): """Foo class.""" # public member def bar(): pass ```

When running python -m interrogate --ignore-semiprivate -vv _test.py, we get the following coverage report:

``` ======================= Coverage for /Users/tnytown/Documents/sw/sigstore-python/test/ ======================== ---------------------------------------------- Detailed Coverage ---------------------------------------------- | Name | Status | |-----------------------------------------------------------|-------------------------------------------------| | _test.py (module) | MISSED | | Foo (L9) | COVERED | | Foo.bar (L13) | MISSED | |-----------------------------------------------------------|-------------------------------------------------| --------------------------------------------------- Summary --------------------------------------------------- | Name | Total | Miss | Cover | Cover% | |-------------------------|--------------------|-------------------|--------------------|---------------------| | _test.py | 3 | 2 | 1 | 33% | |-------------------------|--------------------|-------------------|--------------------|---------------------| | TOTAL | 3 | 2 | 1 | 33.3% | ------------------------------- RESULT: FAILED (minimum: 100.0%, actual: 33.3%) ------------------------------- ```

interrogate skips the semiprivate class and its member, lints the undocumented member of the public class, and also lints the missing module-level docstring. l However, in this situation, I would like interrogate to skip the whole module, as it is semiprivate.

Alternatively, if this isn't something you're comfortable with supporting, maybe the documentation can make it more clear that semiprivateness doesn't affect modules?

I'd be happy to submit a patch for either the behavioral change or the documentation :)

Your Environment