Skip to content

fix(python): read pyproject pytest lists as TOML strings - #315

Closed
sarankumar1325 wants to merge 1 commit into
DiffCI:mainfrom
sarankumar1325:fix/pytest-toml-list-parsing
Closed

sarankumar1325 wants to merge 1 commit into
DiffCI:mainfrom
sarankumar1325:fix/pytest-toml-list-parsing

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Closes #158

readPytestSettings took a [tool.pytest.ini_options] list up to the first ] and splitList split it on whitespace and commas. A TOML comment, or a ] or , inside a quoted string, dropped or invented entries.

Changes in src/repo/adapters/python.ts:

  • New readTomlStringArray reads the array one string at a time. It skips whitespace, line breaks, commas and # comments between entries. Inside a quoted string, ], , and # stay part of the value. Basic strings handle the simple TOML escapes; literal strings are taken as-is.
  • Anything it can't read with certainty sets settings.unreadable, like a non-literal value already does, and DiffCI runs the full suite. That covers a number or a nested array, two commas in a row, a missing ], a multi-line string inside the array, and a \u escape. Nothing is guessed.
  • A single string value (pythonpath = "lib") and multi-line addopts strings work as before. addopts list entries still go through splitList, so the -p plugin detection is unchanged.

Tests in tests/repo/python-adapter.test.ts, covering the three examples from the issue plus:

  • a multi-line list with a trailing comma;
  • 'a,b' and "c # d" kept whole;
  • the unreadable cases above.

Mutation check: with the src/ change reverted, 4 of the new cases fail.

npm test (1244 pass, 0 fail), npm run typecheck and npm run audit:boundary pass. DCO signed off.

The regex took a pytest list up to the first ] and split it on
whitespace and commas, so a comment or a ] or , inside a quoted string
dropped or invented entries. Read the array string by string, skipping
comments, and mark anything it cannot read with certainty as unreadable.
Closes DiffCI#158.

Signed-off-by: sarankumar1325 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:25:34.688061Z a579699 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
The regex took a pytest list up to the first ] and split it on
whitespace and commas, so a comment or a ] or , inside a quoted string
dropped or invented entries. Read the array string by string, skipping
comments, and mark anything it cannot read with certainty as unreadable.
Closes #158.

Signed-off-by: sarankumar1325 <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Merged to main as 11aa2b2 (squashed, authorship kept). It conflicted with #314 only in the test file, so I resolved that on main. Thanks!

adityankale190895 added a commit that referenced this pull request Nov 18, 2026
Credit the pytest configuration fixes (#314, #315, #316) under the
Python fallback reasons, and the pytest declared-inputs example (#319)
next to the example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants