python-template icon indicating copy to clipboard operation
python-template copied to clipboard

Replace prospector with pytest-flake8

Open fdiblen opened this issue 3 years ago • 8 comments

Use flake8 to lint the generated package (https://pypi.org/project/pytest-flake8).

fdiblen avatar Apr 19 '21 13:04 fdiblen

flake8 has a different purpose than prospector. From it's documentation:

Flake8: Your Tool For Style Guide Enforcement

while prospector is

Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and complexity.

so I'm not convinced that replacing it with just flake8 is the right thing to do.

bouweandela avatar Apr 19 '21 13:04 bouweandela

Looking at https://towardsdatascience.com/static-code-analysis-for-python-bdce10b8d287 flake8 plugins could cover prospectors features.

sverhoeven avatar Apr 20 '21 08:04 sverhoeven

For the 0.3.0 release we will keep prospector and use githooks as described in https://github.com/fair-software/howfairis/blob/main/README.dev.rst. Ref: #82

fdiblen avatar Apr 20 '21 09:04 fdiblen

I would like to replace prospector with flake8 with plugins. Prospector is not as widely used as flake8 .

Putting linting in pytest is not the direction I would like to go in as it combines testing and linting which are I feel different tasks.

sverhoeven avatar Apr 20 '21 09:04 sverhoeven

Also propspector pins isort to a very old version (v3).

sverhoeven avatar May 07 '21 10:05 sverhoeven

Looking at https://towardsdatascience.com/static-code-analysis-for-python-bdce10b8d287 flake8 plugins could cover prospectors features.

I would like to replace prospector with flake8 with plugins. Prospector is not as widely used as flake8 .

@sverhoeven Looking at that link, I don't think flake8 includes support for pylint, which to my knowledge, is by the best open-source linting tool for Python available. We also recommend using it in the guide: https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions. I noticed that support for sonar linting services was added to this repository. That could be an alternative to pylint, but does sonar use open-source linting tools to run its service? For consistent results, I would recommend having the same linter locally as in the linter service that is integrated with GitHub.

Putting linting in pytest is not the direction I would like to go in as it combines testing and linting which are I feel different tasks.

I agree. It is possible to run flake8 as a unit test (via pytest-flake8), to enforce a style and maybe catch some of the most obvious mistakes, or you could also run the automatic formatter and make the test fail if it reports changes, but that's as far as I would go. Running a tool like pylint as a unit test is not a good idea because it will report false positives: it tries to guide you in making nice code, but it cannot know everything.

bouweandela avatar May 17 '21 19:05 bouweandela

Sorry, accidentally clicked the close button.

bouweandela avatar May 17 '21 19:05 bouweandela

Another option could be wemake-python-styleguide. It's a shame that it is not compatible with formatters like yapf or black

sverhoeven avatar Aug 12 '21 11:08 sverhoeven

This discussion has been followed up and resolved in #336 and #347.

egpbos avatar Dec 22 '23 13:12 egpbos