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

Đang mở Phù hợp với người mới
#158 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
86/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu tại src/repo/adapters/python.ts, ở readPytestSettings và splitList, sau đó đọc trường hợp some_function() trong tests/repo/python-adapter.test.ts. Bổ sung kiểm thử cho ba ví dụ TOML và một danh sách nhiều dòng có dấu phẩy ở cuối; khiến đầu vào không chắc chắn đặt settings.unreadable. Chạy npm test và xác nhận các giá trị danh sách được giữ nguyên, đồng thời fallback cho đầu vào không đọc được được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
0
Fork
4
Merge trung bình
18 giờ 41 phút
Pull request đã merge (30 ngày)
48

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DiffCI/core

Tất cả issue của DiffCI/core

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.