plone / plone.recipe.codeanalysis

provides static code analysis for Buildout-based Python projects, including flake8, JSHint, CSS Lint, and other code checks
https://pypi.org/project/plone.recipe.codeanalysis/
11 stars 8 forks source link

Can we have something to use pylint to check for pylint Python 3 porting mode, --py3k? #219

Open idgserpro opened 6 years ago

idgserpro commented 6 years ago

In our .travis.yml we use pylint (mainly a pylint --py3k --disable=no-absolute-import $PATH call) to check Python 3 porting mode (since porting to Python 3 is the way to go). I just had a broken build in Travis, I can fix the errors but I would like to have this warning as a pre-commit hook so it's checked in my development machine.

In a nutshell: instead of what we have now for example in buildout.plonetest:

[code-analysis]
recipe = plone.recipe.codeanalysis
directory = src
pre-commit-hook = True
flake8 = True
flake8-ignore = E501
return-status-codes = True

Would receive a pylint-py3k-check, becoming:

[code-analysis]
recipe = plone.recipe.codeanalysis
directory = src
pre-commit-hook = True
flake8 = True
flake8-ignore = E501
return-status-codes = True
pylint-py3k-check = True

And in plone.recipe.codeanalysis https://github.com/plone/plone.recipe.codeanalysis/blob/98ec7c70745b47d3bb67e2e5f61d49725528fed6/plone/recipe/codeanalysis/__init__.py#L205, pylint --py3k --disable=no-absolute-import $PATH would be added to the git pre-commit hooks if pylint-py3k-check is True.

What do you think?

@mauritsvanrees (since I'm quoting buildout.plonetest) and @hvelarde (since https://github.com/plonegovbr/brasil.gov.portal/pull/422 will become commonplace).

mauritsvanrees commented 6 years ago

I use flake8, and have a Python 2 and a Python 3 virtualenv with flake8 installed, and I check compatibility by calling both commands. Using two different Python versions will not work in a buildout though.

I am not using pylint myself, so I have no idea if this command is sane. I don't even have pylint installed, so the pre commit hook would currently fail for me.

But the idea seems okay.

hvelarde commented 6 years ago

@mauritsvanrees please check this: https://community.plone.org/t/6226/25

idgserpro commented 6 years ago

I am not using pylint myself, so I have no idea if this command is sane. I don't even have pylint installed, so the pre commit hook would currently fail for me.

My example should have been more complete: pylint would become a dependency for plone.recipe.codeanalysis.

Bu I do agree more discussion would be useful. For example, instead of adding --disable=no-absolute-import to pylint command, having pylint-py3k-check = True would just run pylint --py3k $PATH. If someone want to add more arguments, a pylint-py3k-check-arguments could be added (something like https://github.com/plone/simple-plone-buildout/blob/7d424b0d970f706cc34b7b0b55a40929649f43c6/profiles/debug.cfg#L72).