[elbe-devel] RFC: using pep8 coding style

Manuel Traut manuel.traut at linutronix.de
Wed Dec 20 14:17:44 CET 2017


On Wed, Dec 20, 2017 at 01:34:30PM +0100, Torben Hohn wrote:
> On Tue, Dec 19, 2017 at 04:30:52PM +0100, Manuel Traut wrote:
> > Hi,
> > 
> > i would like to have a common coding style in elbe.
> > PEP8 [0] describes a style-guide for python code.
> > 
> > There is tooling to check the coding style and for automatic refactoring.
> > So it would be easy to ensure that we follow this coding style in the future.
> > 
> > $ cd elbe
> > $ pycodestyle --statistics .
> > 
> > reports about 7000 coding style violations currently. After running
> > 
> > $ autopep8 -i -r -a -a -j 5 .
> > 
> > pycodestyle reports just about 100 violations. Most of them are 'E501 line to
> > long' and some others. All can be easily fixed 'by hand':
> > 
> > 7       E211 whitespace before '('
> > 6       E265 block comment should start with '# '
> > 3       E266 too many leading '#' for block comment
> > 2       E402 module level import not at top of file
> > 98      E501 line too long (82 > 79 characters)
> 
> I am against 80 char lines. It seems to be configurable, and i would
> like to see 120 or something.

It is configurable. However PEP8 says:

"Limit all lines to a maximum of 79 characters.

For flowing long blocks of text with fewer structural restrictions (docstrings
or comments), the line length should be limited to 72 characters."

I would prefer to have 80 chars.

> i generally set the tabwidth to 8. This is different to what manut does.

I use 2 at the moment. I think we should also follow PEP8 and use 4 spaces.

> 
> > 7       E741 ambiguous variable name 'l'
> > 
> > 
> > However an initial conversion introduces a lot of changes and so lowers the
> > usability of git-blame:
> > 
> > $ git diff | diffstat | tail -1
> >  94 files changed, 6206 insertions(+), 4850 deletions(-)
> > 
> > elbe is currently about 12k of python. So nearly every other line will be
> > changed by the cleanup!
> > 
> > I would like to do the conversion in multiple patches. One big patch, that
> > applies the changes from autopep8. And one single patch for each kind of error
> > detected by pycodestyle.
> > 
> > What do you think?
> 
> i am fine with that.
> 
> 
> -- 
> Mit freundlichen Grüßen
> Torben Hohn
> 
> Linutronix GmbH
> 
> Standort: Bremen
> 
> Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> 
> Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
> Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
> Nr. / Trade register no.: 700 806
> 
> Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
> 
> Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
> benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
> möglich ist, durch Antwort-Mail. Vielen Dank!





More information about the elbe-devel mailing list