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

limit docstrings and comments to 79 characters #207

Merged
merged 3 commits into from
Mar 10, 2024
Merged

Conversation

fohrloop
Copy link
Owner

@fohrloop fohrloop commented Mar 10, 2024

This project has followed the following convention from the start:

  • code limited to 88 characters (Black code style)
  • Docstrings and comments limited to 79 characters.

Enforce this by adding the rule W505 for ruff.

Thoughts

Although the exact numbers (79 and 88) could also be something else
and still offer a good developer (and code reading) experience, those
numbers are pretty close to optimal. The reason for this is that I,
among many others develop on small screen (laptop). I also use a large
font / small resolution (which makes font larger) to make it easier for
my eyes. As it's pretty common to need to have code side by side, the
roughly 88 characters starts to be absolute maximum so one does not need
to do horizontal scrolling.

There must be some reason people like to have shorter docstrings than
the actual code.

  • PEP8: 72 for comments, 79 for code
  • Django code style: 79 for comments, 88 for code.

Could perhaps some day use same line length for code and comments, but
even with the 79 char limit the experience has been quite good and the
code looks easy to read in my opinion.

Refs:
https://peps.python.org/pep-0008/
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style

@fohrloop fohrloop merged commit 0a2b79a into dev Mar 10, 2024
6 checks passed
@fohrloop fohrloop deleted the max-doc-length branch March 10, 2024 12:53
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 this pull request may close these issues.

1 participant