python-template
python-template copied to clipboard
Replace prospector with pytest-flake8
Use flake8 to lint the generated package (https://pypi.org/project/pytest-flake8).
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.
Looking at https://towardsdatascience.com/static-code-analysis-for-python-bdce10b8d287 flake8 plugins could cover prospectors features.
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
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.
Also propspector pins isort to a very old version (v3).
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.
Sorry, accidentally clicked the close button.
Another option could be wemake-python-styleguide. It's a shame that it is not compatible with formatters like yapf or black
This discussion has been followed up and resolved in #336 and #347.