More fine-grained control of docstring and comment length

オープン
#906 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

まず #344 の議論とこの Issue に対する 2 件のコメントを確認してください。特に、複数行の docstrings、1 行の docstrings、コメントブロックに対して提案されているデフォルト値を確認します。メンテナーが設定と動作について合意し、実装が未解決の設計上の問題なしにドキュメント化された例を網羅した時点で、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

As discussed/hijacked in #344, I proposed to have an option to limit the length of docstring and comments:

  1. Multi-line docstring: max_doc_length, default to max_line_length (current behavior)
  2. Single-line docstring: max_single_doc_length, default to max_doc_length + 3 if max_doc_length is set, otherwise to max_line_length
  3. Comment block: max_comment_length, default to max_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?

主要言語
Python
スター
5.2k
フォーク
765
平均マージ
1日 20時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PyCQA/pycodestyle のほかの issue

PyCQA/pycodestyle の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。