Skip to content

Use default line lenght of 79 characters #388

Closed

Description

@bouweandela

For some reason, the generated package has a default line length of 120 characters instead of the 79 prescribed by PEP-8: https://peps.python.org/pep-0008/#maximum-line-length

Since we recommend following PEP-8 in the guide we should do the same thing here.

Having a limited line length also encourages people to avoid code with a high complexity (e.g. deeply nested for loops and if statements) since it just doesn't fit on the line.

Activity

  1. egpbos commented on May 14, 2024

    @egpbos
    Collaborator

    I personally change this always to something like 120, so it may have been me who did this. I'm fine with changing the default, though.

  2. BSchilperoort commented on May 24, 2024

    @BSchilperoort

    Personally I am a fan of a slightly longer line length, following the reasoning laid out here.

    Especially with code for scientific purposes, slightly longer/more explicit function or variable names can make things more readable, and a longer line length makes it a bit easier to have longer names.

    Even without nested loops, a single level loop in a class method starts 12 characters in already.

    The exact PEP8 line length of 79 is just a legacy from IBM punch cards.

  3. sjvrijn commented on May 26, 2024

    @sjvrijn
    Contributor

    I'd be in favor of lines longer than 79 characters too.

    The linked PEP8 section explicitly mentions 99 as a viable option:

    Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the line length limit up to 99 characters, provided that comments and docstrings are still wrapped at 72 characters.

  4. bouweandela commented on Jun 5, 2024

    @bouweandela
    MemberAuthor

    The point of this issue was that we recommend following the conventions in PEP-8 in the guide and that the template should reflect that, not to start a discussion on what the best line length is. Apparently, that is so controversial that even black does not dare to take a decision on it. Of course, everyone is free to change it to their own liking in their own projects, but the template should use the default.

  5. DaniBodor commented on Jun 14, 2024

    @DaniBodor
    Collaborator

    Maybe make it a question when setting up the cookiecutter and default it to the 79?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions