[openstack-dev] [nova] pep8 failures on master

Doug Hellmann doug at doughellmann.com
Tue Apr 3 22:52:19 UTC 2018


Excerpts from Michael Still's message of 2018-04-03 22:23:10 +0000:
> I think the bit I am lost on is the concept of running pep8 "under" a
> version of python. Is this an artifact of what version of pep8 I have
> installed somehow?
> 
> If the py3 pep8 is stricter, couldn't we just move to only that one?

It's the same code, but that code is installed into the python3
interpreter's site-packages directory and the console script indicates
that it should execute the python3 interpreter to run the script,
then some checks are added or changed.

Tox assumes if you don't specify otherwise that it should use the
interpreter it's running under to create any virtualenvs used for
tests. On most systems that default is still python2, but it is
possible to install tox under python3 and then the default is
python3.  You can set basepython=python3 in tox.ini under the pep8
section to force the use of python3 [1] and remove the ambiguity.

That's something we're going to need to do as we transition to
python 3 anyway, because at some point the "default" python in CI
will be python 3 and we're going to want to ensure that developers
working on their local system see the same behavior.

Doug

[1] https://tox.readthedocs.io/en/latest/config.html#confval-basepython=NAME-OR-PATH

> 
> Michael
> 
> On Wed., 4 Apr. 2018, 8:19 am Kevin L. Mitchell, <klmitch at mit.edu> wrote:
> 
> > On Wed, 2018-04-04 at 07:54 +1000, Michael Still wrote:
> > > Thanks to jichenjc for fixing the pep8 failures I was seeing on
> > > master. I'd decided they were specific to my local dev environment
> > > given no one else was seeing them.
> > >
> > > As I said in the patch that fixed the issue [1], I think its worth
> > > exploring how these got through the gate in the first place. There is
> > > nothing in the patch which stops us from ending up here again, and no
> > > real explanation for what caused the issue in the first place.
> >
> > While there was no discussion in the patch, the topic of the patch
> > hints at the cause: "fix_pep8_py3".  These were probably pep8 errors
> > that would only occur if pep8 was running under Python 3 and not Python
> > 2.  The first error was fixed by removing a debugging print that was
> > formatted as "print (…)", which would satisfy pep8 under Python 2—since
> > 'print' is a statement—but not under Python 3, where it's a function.
> > The second error was in a clause protected by six.PY2, and was caused
> > by "unicode" being missing in Python 3; the solution jichenjc chose
> > there was to disable the pep8 check for that line.
> >
> > The only way I can imagine stopping these errors in the future would be
> > to double-up on the pep8 check: have the gate run pep8 under both
> > Python 2 and Python 3.
> > --
> > Kevin L. Mitchell <klmitch at mit.edu
> > >__________________________________________________________________________
> > OpenStack Development Mailing List (not for usage questions)
> > Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> >



More information about the OpenStack-dev mailing list