I have seen some pull requests introducing conditional code for Python 2 and 3 compatibility. Can we please instead of doing this for every module use the six module https://pythonhosted.org/six/, since this is a Zope? dependency already. I don't see any shortcomings there, or did I miss something?
It is supported
It is easier to understand
It is easier to clean up, if we go for Python3 only
I know but I want to check my code under Python 2.7 and get recommendations on what needs to be migrated; as stated in GitHub, we need more like a linter because this is going to be really hard.
I was checking Pylint again but I remembered why I just stopped trying to use it years ago: it's way too complex for beginners.
anyway, does anybody has a good .pylintrc file to begin with for Zope/Plone projects?
or, does anybody has tried to run sixer on CI? with Python 3, of course
$ pylint --py3k --disable=no-absolute-import src/collective/lazysizes/
No config file found, using default configuration
************* Module collective.lazysizes.vocabularies
W: 13,22: Calling a dict.iter*() method (dict-iter-method)
-----------------------------------
Your code has been rated at 9.98/10
$ echo $?
4
$ pylint --py3k --disable=no-absolute-import src/collective/fingerpointing/
No config file found, using default configuration
------------------------------------
Your code has been rated at 10.00/10
$ echo $?
0
I'm disabling no-absolute-import because we already check for that with plone.recipe.codeanalysis, and is generating a lot of noise.
thanks, I had noticed that. in fact the issue is a little bit different, if I run Pylint without the --disable=no-absolute-import I get a lot of useless warnings like these:
$ pylint --py3k src/collective/fingerpointing/
No config file found, using default configuration
************* Module collective.fingerpointing
W: 2, 0: import missing `from __future__ import absolute_import` (no-absolute-import)
...
************* Module collective.fingerpointing.upgrades.v3
W: 2, 0: import missing `from __future__ import absolute_import` (no-absolute-import)
W: 3, 0: import missing `from __future__ import absolute_import` (no-absolute-import)
-------------------------------------------------------------------
Your code has been rated at 7.79/10 (previous run: 10.00/10, -2.21)
Making sure this propagates if the use of pylint is to spread within the Plone circles. I've seen people not use pylint because it is beyond verbose upon this particular failure and that is a shame.
I recommend wrapping the config and running of pylint with pylama (or pyflakes) and starting to build a setup.cfg. Both wrappers support rather nice exclusion, inclusion etc. schemes for the configuration. Here is one of mine for loose reference and inspiration:
And you can run just one (or any subset) of the linters at a time with a --linters flag and that still respects the skip declarations and linter definitions from the config.
Since we got into this already: Have you had any fun with BBB or interface inheritance yet with pylint? It does not deal super well with old-style classes or the Zope "new style" classes (mostly stuff leaning on ExtensionClass). Sharing of all anecdotes / tips / tricks is welcome.
the results are mixed: locally collective.lazysizes returned a warning that should make the build fail (see above), but that's not happening and I don't know why: