econchick / interrogate

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

-I doesn't work with pre-commit #100

Open lorenzomammana opened 2 years ago

lorenzomammana commented 2 years ago

Environment

Description of the bug

I'm trying to use interrogate through pre-commit with this hook

  - repo: https://github.com/econchick/interrogate
    rev: 1.5.0
    hooks:
      - id: interrogate
        language: python
        types: [python]
        args:
          [
            "-vv",
            "-i",
            "-I",
            "-M",
            "--fail-under=60",
         ]

If I run pre-commit run --all-files I obtain

| TOTAL                                         |   517 |  378 |   139 |  26.9% |
--------------- RESULT: FAILED (minimum: 60.0%, actual: 26.9%) ----------------

If instead I run interrogate -vv -i -I -M --fail-under=60 . I obtain

| TOTAL                                                      |             491 |            364 |             127 |            25.9% | 
------------------------------------------- RESULT: FAILED (minimum: 60.0%, actual: 25.9%) ------------------------------------------- 

That is because in the first case __init__.py are not ignored, while in the second case they are correctly ignored as by -I documentation.

I've done the test also on -M and -i but these two parameter works properly resulting in the same output on both executions.

What you expected to happen

Output of both run should be exactly the same

How to reproduce (as minimally and precisely as possible)

Run interrogate with -I parameter using pre-commit and using cli on an __init__.py file that lacks documentation, the one from cli should pass, the one from interrogate should wrongly fail.

Anthing else we need to know?

I guess it's pretty much the same problem of #60 but here there's no workaround!

jimrybarski commented 10 months ago

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