Skip to content

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

Closed

Description

@adityankale190895

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.

Activity

  1. added
    bug
    good first issue
    on Nov 17, 2026
  2. added a commit that references this issue on Nov 18, 2026
    11aa2b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapterbuggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions