Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its value

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
tooling

調査の方向性

まず commit 926d9f0 と、括弧で囲まれた連結における三重引用符文字列の扱いを確認します。提供されている t.py の再現コードに docformatter --in-place を使用し、その後 Python で実行して X の結果の値を比較します。この非 docstring リテラルが変更されず、既存のフォーマット動作が引き続き機能すれば完了です。

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

説明

C: convention P: bug U: high

docformatter 1.7.8 treats a triple-quoted string that opens a parenthesized concatenation as a docstring and reformats its contents: it splits the first sentence off, indents the remainder by four spaces, and moves the closing quotes onto their own line. The file still compiles, so the only effect is that the string the program builds is wrong.

Reproducer

X = (
    """#!/bin/bash
# Ends here.
# A second line.
_real="""
    + "y"
)
$ docformatter --in-place t.py
$ python3 -c "ns={}; exec(open('t.py').read(), ns); print(repr(ns['X']))"
version value of X
1.7.7 '#!/bin/bash\n# Ends here.\n# A second line.\n_real=y'
1.7.8 '#!/bin/bash\n# Ends here.\n\n # A second line.\n _real=\n y'

No config file and no flags are needed. The trigger is the string's position: the same literal assigned directly to a name is left alone.

# Ends here. matters because the trailing period is what makes docformatter treat the first line as a summary and split a description off after it.

Scale

Running 1.7.7 and 1.7.8 over the same 1,257-file tree, one file at a time, on CPython 3.11: of the 1,250 files both versions processed without error, 475 come out different. Most are docstring-formatting changes that look intentional, but this class is in there and is invisible: the output parses, so nothing downstream complains.

Root cause

git bisect between v1.7.7 and 1b3f03d names 926d9f0 ("refactor: split long functions into smaller functions", #318) as the first bad commit. Its parent fe1a85f is clean. Being a refactor, the behavior change looks unintended.

This is the same family as #344 (non-docstring literals in call arguments), but a different position: a parenthesized concatenation rather than a call argument, so #364 does not cover it. The reproducer above works as a test case.

Environment

CPython 3.11.15, Linux x86-64, docformatter==1.7.8 from PyPI. Still present on master.

主要言語
Python
スター
598
フォーク
93
平均マージ
12日 10時間
マージ済み PR(30日)
1

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

PyCQA/docformatter のほかの issue

PyCQA/docformatter の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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