More fine-grained control of docstring and comment length
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
As discussed/hijacked in #344, I proposed to have an option to limit the length of docstring and comments:
- Multi-line docstring:
max_doc_length, default tomax_line_length(current behavior) - Single-line docstring:
max_single_doc_length, default tomax_doc_length + 3ifmax_doc_lengthis set, otherwise tomax_line_length - Comment block:
max_comment_length, default tomax_doc_length(current behavior)
Answer to @asottile
I don't think the complexity of a bunch of new settings is a good idea -- also your current proposal allows single line docstrings to extend beyond
max_line_length
I added that to the proposal. My rational is, consider these
"""Something that span 72 columns.
Some additional description.
"""
"""The same first line."""
then the second case actually reaches 75 columns. I'm not sure about others, but I consider
"""Blah blah blah.
"""
to be quite distasteful.
Answer to @timj
I'm really happy with the current situation and have no problem forcing my comment lines to match the docstring constraint.
Generally, I have no problem with breaking comments, but in a few places like copyright headers, it's not very nice, like in AGPL or LGPL:
# foobar is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# foobar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with foobar. If not, see <https://www.gnu.org/licenses/>.
As you can see, the second-last line is 74 columns, and breaking it in any manner makes it look awkward, especially when these should be consistent between different languages.
Also to @brianv0, what's your opinion on this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the discussion in #344 and the two comments on this issue, especially the proposed defaults for multi-line docstrings, single-line docstrings, and comment blocks. The work is done when the maintainers agree on the settings and behavior and the implementation covers the documented examples without unresolved design questions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100