Skip to content

--zero-exit on CI and pre-commit gives false negative #594

@abelsiqueira

Description

@abelsiqueira

cc @sjvrijn @luisaforozco which helped track this down

Description

I noticed that both the CI [1] and the pre-commit [2] use --zero-exit. But --zero-exit is telling prospector to ignore the issues it found, since the flag check [3] is run before the length of the messages check [4].

I think that defeats the purpose of having it on the CI and pre-commit.
As an example, I ran prospector on this repo and got 24 issues.[5]

[1] https://github.com/PyCQA/prospector/blob/197622ef559b2056c7d3fa486be84d9251026be7/.github/workflows/tests.yml#L31

[2] https://github.com/PyCQA/prospector/blob/197622ef559b2056c7d3fa486be84d9251026be7/.pre-commit-config.yaml#L42

[3] https://github.com/PyCQA/prospector/blob/866b79ed7aa381266939bcac952df40993dbfad3/prospector/run.py#L201-L204

[4]
https://github.com/PyCQA/prospector/blob/866b79ed7aa381266939bcac952df40993dbfad3/prospector/run.py#L209-L211

[5]

$ poetry run prospector
...
=================
         Started: 2023-02-20 15:42:43.808330
        Finished: 2023-02-20 15:42:53.087899
      Time Taken: 9.28 seconds
       Formatter: grouped
        Profiles: .prospector.yml, no_doc_warnings, no_member_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh
      Strictness: from profile
  Libraries Used: 
       Tools Run: dodgy, mypy, profile-validator, pycodestyle, pyflakes, pylint
  Messages Found: 24
 External Config: pylint: ####/prospector/pyproject.toml

Expected result

  • Expected prospector to return 0 issues on prospector.
  • Maybe change flag to --ignore-errors to make the purpose clearer.

Environment (please complete the following information):

  • OS: linux
  • poetry run prospector
  • Version 1.9.1
  • Python 3.9.16

Additional context

I was trying to change from a manual .githooks/pre-commit configuration to pre-commit (https://pre-commit.com). The project passes prospector but was failing pre-commit run -a (with pylint: import-error / Unable to import). I was looking through other pre-commit configs trying to fix it and noticed that the zero-exit flag could lead to errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions