Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default line lenght of 79 characters #388

Closed
bouweandela opened this issue May 7, 2024 · 5 comments · Fixed by #389
Closed

Use default line lenght of 79 characters #388

bouweandela opened this issue May 7, 2024 · 5 comments · Fixed by #389

Comments

@bouweandela
Copy link
Member

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.

@egpbos
Copy link
Member

egpbos commented May 14, 2024

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.

@BSchilperoort
Copy link

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.

@sjvrijn
Copy link
Contributor

sjvrijn commented May 26, 2024

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.

@bouweandela
Copy link
Member Author

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.

@DaniBodor
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants