econchick/interrogate

__init__.py files included despite pyproject.toml negating them

rjalexa opened this issue · 3 comments

Environment

  • interrogate version(s) (interrogate --version: version 1.5.0
  • Operating System(s): Mac OS Ventura 13.2.1
  • Python version(s): 3.10.9

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?

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.

Add pass_filenames: false to your hook. See: #60 (comment)

Thank you!