pyproject.toml: a comment or `]` inside a pytest list drops entries

オープン 初心者向け
#158 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
testing

調査の方向性

src/repo/adapters/python.ts の readPytestSettings と splitList から始め、次に tests/repo/python-adapter.test.ts の some_function() のケースを読みます。3つの TOML の例と、末尾にカンマがある複数行のリストのテストを追加し、不確かな入力では settings.unreadable が設定されるようにします。npm test を実行し、リストの値が保持されることと、読み取り不能時のフォールバックがテストでカバーされていることを確認します。

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

説明

adapter bug good first issue

readPytestSettings in src/repo/adapters/python.ts reads python_files, testpaths and pythonpath from [tool.pytest.ini_options] with a regex. The regex takes everything up to the first ], and splitList splits it on whitespace and commas. TOML comments and brackets inside strings both break this:

[tool.pytest.ini_options]
python_files = [
  "test_*.py",  # see [docs]
  "check_*.py",
]

Today this returns ["test_*.py", "#", "see", "[docs"], which drops check_*.py. With the comment # unit instead, it returns ["test_*.py", "#", "unit", "check_*.py"]. testpaths = ["tests/[a]", "integration"] returns ["tests/[a"], which drops integration.

Done when:

  • Comments outside strings are ignored, and a ] or , inside a quoted string stays part of the value. Splitting the list into quoted strings works better than splitting on whitespace.
  • Anything the reader can't parse with certainty sets settings.unreadable, as a non-literal value already does (see the some_function() case in the test). DiffCI then runs the full suite, which is safe. Never guess.
  • tests/repo/python-adapter.test.ts has cases for the three examples above, plus a multi-line list with a trailing comma.

New to DiffCI? See CONTRIBUTING.md: add a synthetic fixture, run npm test, and sign off commits with git commit -s. Comment here to claim the issue.

主要言語
TypeScript
スター
0
フォーク
4
平均マージ
18時間 41分
マージ済み PR(30日)
48

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

DiffCI/core のほかの issue

DiffCI/core の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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