Indentation characters of the original code are not preserved
まだ誰も着手していません。
評価
調査の方向性
まず _do_add_formatted_docstring と _do_add_unformatted_docstring から始め、次に _do_format_code とその tokenize.untokenize の使用箇所を調べます。提供されたタブインデントの再現コードを docformatter で実行し、docstring 内およびコードの継続行にあるタブがタブのまま維持され、なおかつフォーマットが正常に機能することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
docformatter unnecessarily replaces tab characters with spaces. When a file
uses tabs, running docformatter on it changes indentation characters both
inside docstrings and in code outside the docstring.
Reproducer
def some_function(
a_parameter
):
"""Important documentation.
with an indented item
"""
...
$ docformatter file.py
--- before/file.py
+++ after/file.py
@@ -1,8 +1,8 @@
def some_function(
- a_parameter
+ a_parameter
):
"""Important documentation.
- with an indented item
- """
+ with an indented item
+ """
...
Cause
Two independent code paths substitute spaces for the original indentation
characters:
-
_do_add_formatted_docstringand_do_add_unformatted_docstringbuild
the indent for the docstring's internal lines as" " * token.start[1],
based on the docstring's opening line. When the opening line is indented with
a tab, each tab inside the docstring is replaced by a single space. -
_do_format_coderuns the whole file throughtokenize.untokenize,
which reconstructs inter-token whitespace as" " * col_offset. This means
that tabs on continuation lines are also replaced by a single space.
- 主要言語
- Python
- スター
- 598
- フォーク
- 93
- 平均マージ
- 12日 10時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PyCQA/docformatter のほかの issue
-
fresh
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
PyCQA/docformatter#385 ·
-
C: convention P: bug U: high
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
PyCQA/docformatter#367 · コメント 1 件 ·
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueオープンC: convention P: bug U: high
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
PyCQA/docformatter#366 ·
-
fresh
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
PyCQA/docformatter#354 · リアクション 3 件 ·
-
C: stakeholder P: enhancement U: low
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
PyCQA/docformatter#346 ·
PyCQA/docformatter の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
letsencrypt/cp-cps#353 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
PedestrianDynamics/pyFDS-Evac#394 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DOI-USGS/pywatershed#421 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-pillow/Pillow#10087 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信