# LSST python coding style delta to PEP8

XMLWordPrintable

## Details

• Type: RFC
• Status: Implemented
• Resolution: Done
• Component/s:
• Labels:
None

## Description

The LSST project will adopt PEP8 as the python coding standard, with the following modifications. Our current python coding standard will be reduced to a link to PEP8 https://www.python.org/dev/peps/pep-0008/
, a list of the items where we differ from PEP8, and the remaining items in our current standard that PEP8 is silent on (some of which-e.g. use of super()-will be revisited in a future RFC).

pep8+flake8+pep8-naming modifications and ignore list:

max-line-length = 110
E133: closing bracket is missing indentation
E226: missing whitespace around arithmetic operator
E228: missing whitespace around bitwise or shift operator
E251: unexpected spaces around keyword / parameter equals
N802: function name should be lowercase
N803: argument name should be lowercase
W391: blank line at end of file

Example flake8 configuration file:

 [flake8] max-line-length = 110 ignore = E133, E226, E228, E251, N802, N803, W391 

Example SublimeLinter-flakes configuration for SublimeText:

  "flake8": {  "ignore": "E133,E226,E228,E251,N802,N803,W391",  "jobs": "1",  "max-complexity": -1,  "max-line-length": 110,  "show-code": false  }, 

SQuaRE has agreed to support this transition by supplying a flake8 linter configuration (example above), documentation updates, and CI support (further in the future).

For the curious, we took notes in this Google doc to identify the similarities and differences between PEP8 and the LSST python coding standards.

## Activity

Hide
Kian-Tat Lim added a comment -

A reminder: any style cleanups should generally occur in separate commits from other code changes.

Show
Kian-Tat Lim added a comment - A reminder: any style cleanups should generally occur in separate commits from other code changes.
Hide
Jonathan Sick added a comment -

As I mentioned on HipChat, in sqre-codekit we developed the ability to do automatic bulk edits of the entire LSST Stack (in the context of RFC-45). If we believe in the veracity of autopep8, we could extend codekit to also automatically fix pre-existing PEP8 issues. On the other hand, there is value in not being blocked by the worker that needs to implement this automation.

Show
Jonathan Sick added a comment - As I mentioned on HipChat, in sqre-codekit we developed the ability to do automatic bulk edits of the entire LSST Stack (in the context of RFC-45 ). If we believe in the veracity of autopep8 , we could extend codekit to also automatically fix pre-existing PEP8 issues. On the other hand, there is value in not being blocked by the worker that needs to implement this automation.
Hide
Kian-Tat Lim added a comment - - edited

I don't believe it will be easy to have autopep8 format code to fit our deltas to PEP8, so I'm not sure this is a solution (it might form the basis of one, however).

Show
Kian-Tat Lim added a comment - - edited I don't believe it will be easy to have autopep8 format code to fit our deltas to PEP8, so I'm not sure this is a solution (it might form the basis of one, however).
Hide
John Parejko added a comment -

autopep8 has this option:

--ignore errors do not fix these errors/warnings (default: E24)

Show
John Parejko added a comment - autopep8 has this option: --ignore errors do not fix these errors/warnings (default: E24)
Hide
Kian-Tat Lim added a comment -

Also I just noticed --select in the documents. So this could provide some assistance.

Show
Kian-Tat Lim added a comment - Also I just noticed --select in the documents. So this could provide some assistance.

## People

• Assignee:
John Parejko
Reporter:
John Parejko
Watchers:
Chris Walter, David Reiss, Frossie Economou, Gregory Dubois-Felsmann, John Parejko, John Swinbank, Jonathan Sick, Kian-Tat Lim, Mario Juric, Michael Reuter, Michael Wood-Vasey, Nate Lust, Paul Price, Russell Owen, Simon Krughoff, Tim Jenness