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

Docformatter produces error when parsing docstring with Ruff noqa at the end

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

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

評価

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

調査の方向性

提供された Python docstring の例を再現し、末尾の Ruff noqa コメント周辺のトークン位置に重点を置いて、tokenize.untokenize を通して docformatter/format.py を追跡する。フォーマットが ValueError なしで完了し、noqa ディレクティブが保持されれば完了とする。

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

説明

C: stakeholder P: enhancement U: low

When a docstring has a noqa directive at the end (used for suppressing one off linting errors in a docstring), docformatter throws an error.

Ex:
File:

"""
conf.py
~~~~~~~

Copyright (C) 2024 Noah Jenner under CC BY-SA 4.0.
To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0/

------------------------------------------------------------------------

Configuration file for Sphinx.
"""  # noqa: D205, D400

Error output:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\noahj\.local\bin\docformatter.exe\__main__.py", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\__main__.py", line 144, in main
    return _main(
        sys.argv,
    ...<2 lines>...
        standard_in=sys.stdin,
    )
  File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\__main__.py", line 134, in _main
    return formator.do_format_files()
           ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 649, in do_format_files
    result = self._do_format_file(filename)
  File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 815, in _do_format_file
    formatted_source = self._do_format_code(source)
  File "C:\Users\noahj\AppData\Roaming\uv\data\tools\docformatter\Lib\site-packages\docformatter\format.py", line 876, in _do_format_code
    _code = tokenize.untokenize(self.new_tokens)
  File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 341, in untokenize
    out = ut.untokenize(iterable)
  File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 262, in untokenize
    self.add_whitespace(start)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "C:\Users\noahj\AppData\Roaming\uv\data\python\cpython-3.14.2-windows-x86_64-none\Lib\tokenize.py", line 178, in add_whitespace
    raise ValueError("start ({},{}) precedes previous end ({},{})"
                     .format(row, col, self.prev_row, self.prev_col))
ValueError: start (11,5) precedes previous end (12,0)

This occurs regardless of options passed into the command line.

Removing the directives does fix the problem, though this reintroduces linting errors produced by Ruff or other linters.

主要言語
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 を短くまとめたダイジェスト。