econchick / interrogate

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

__init__.py files included despite pyproject.toml negating them #145

Closed rjalexa closed 6 months ago

rjalexa commented 1 year ago

Environment

Description of the bug

pyproject.toml option ignore-init-module = true gets honoured when interrogate is launched from command line, but is NOT honoured when invoked from pre-commit

What you expected to happen

I would expect my init.py to be ignored when interrogate is invoked either way (command line or pre-commit)

How to reproduce (as minimally and precisely as possible)

.pre-commit-config.yaml contains the following:

repos:
  - repo: https://github.com/econchick/interrogate
    rev: 1.5.0
    hooks:
      - id: interrogate

pyproject.toml

[tool.interrogate]
ignore-init-method = true
ignore-init-module = true
ignore-magic = false
ignore-semiprivate = false
ignore-private = false
ignore-property-decorators = false
ignore-module = false
ignore-nested-functions = false
ignore-nested-classes = true
ignore-setters = false
fail-under = 95
exclude = ["docs", "rja_dev"]
ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"]
# possible values: 0 (minimal output), 1 (-v), 2 (-vv)
verbose = 1
quiet = false
whitelist-regex = []
color = true
omit-covered-files = false
generate-badge = "."
badge-format = "svg"

Run from pre-commit:

(memaback-py3.10) (base) bob@Roberts-Mac-mini memaback % pre-commit run --all-files
interrogate..............................................................Failed
- hook id: interrogate
- exit code: 1

= Coverage for /Users/bob/Documents/work/code/memaback/ =
- Summary -
| Name                                         | Total | Miss | Cover | Cover% |
|----------------------------------------------|-------|------|-------|--------|
| src/memaback/__init__.py                     |     1 |    1 |     0 |     0% |
| src/memaback/mema_fetch_article_url.py       |     8 |    0 |     8 |   100% |
| src/memaback/mema_nlp_ensemble_experiment.py |    16 |    0 |    16 |   100% |
| tests/__init__.py                            |     1 |    1 |     0 |     0% |
| tests/test_mongoconn.py                      |     2 |    0 |     2 |   100% |
|----------------------------------------------|-------|------|-------|--------|
| TOTAL                                        |    28 |    2 |    26 |  92.9% |
- RESULT: FAILED (minimum: 95.0%, actual: 92.9%) -
Generated badge to /Users/bob/Documents/work/code/memaback/interrogate_badge.svg

Anthing else we need to know?

pawel-czyz commented 1 year ago

I'm using Python 3.9.7 and interrogate 1.5.0 and I have observed similar behavior with respect to the exclude argument:

$ interrogate quiet   # Works properly
$ pre-commit run
interrogate..............................................................Failed
- hook id: interrogate
- exit code: 1

and the error is due to one of the files which are listed in exclude.

jimrybarski commented 1 year ago

Add pass_filenames: false to your hook. See: https://github.com/econchick/interrogate/issues/60#issuecomment-735436566

pawel-czyz commented 1 year ago

Thank you!