#36500: pre-commit should enforce 79 char limit for docstrings and comments
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Mike
Type: | Edmunds
Cleanup/optimization | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):
* component: Documentation => Uncategorized
Comment:
This issue is about the max line length for triple-quoted
`"""docstrings"""` and `# comment lines` in .py files in the django/ and
tests/ directories. (The PR Jacob linked is for reStructuredText .txt
files in the docs/ directory, which have a similar length restriction but
are otherwise unrelated to this issue. I'm not sure what the correct
category is, but it's not "Documentation".)
Right now, Django's Linters CI job and pre-commit checks enforce only the
88-char overall limit in .py files. The smaller 79-char limit for
docstrings and comments is enforced manually during PR review, if the
reviewer happens to notice it. This creates extra hurdles and noise for
both reviewers and contributors.
Unfortunately, the limit for docstrings and comments hasn't been
consistently enforced, and there are over 1300 cases where Django's
existing .py code doesn't comply with its own style requirements (see
https://github.com/django/django/pull/19627#issuecomment-3050890027).
So setting flake8 `max-doc-length = 79` would require fixing all those
exceptions first, or grandfathering them in (e.g., by listing the problem
files in .flake8 `per-file-ignores`).
An alternative might be adding `args: ["--max-docs-length=79"]` to the
flake8 section of pre-commit-config.yaml. That would make pre-commit
enforce the limit on modified files, without needing to address all the
existing violations. The downside is it only works for people who have
configured pre-commit, and the CI Linters job wouldn't catch the problem.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36500#comment:3>