Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-162

LSST python coding style delta to PEP8

    Details

    • Type: RFC
    • Status: Implemented
    • Resolution: Done
    • Component/s: DM
    • 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.

        Attachments

          Issue Links

            Activity

            Hide
            ktl Kian-Tat Lim added a comment -

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

            Show
            ktl Kian-Tat Lim added a comment - A reminder: any style cleanups should generally occur in separate commits from other code changes.
            Hide
            jsick 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
            jsick 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
            ktl 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
            ktl 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
            Parejkoj John Parejko added a comment -

            autopep8 has this option:

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

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

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

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

              People

              • Assignee:
                Parejkoj John Parejko
                Reporter:
                Parejkoj 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
              • Votes:
                1 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Planned End:

                  Summary Panel