Bug: single-quoted strings in `pyproject.toml` are ignored

Đang mở Phù hợp với người mới
#706 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
85/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ệ
python, typescript
Lĩnh vực
cli, testing-qa

Hướng nghiên cứu

Bắt đầu tại src/core-open/scanners/python-scanner.ts, đọc parsePyprojectToml, appendPoetryDependencyTable và helper collectQuotedStrings hiện có để xem scanner xử lý cả hai kiểu dấu nháy như thế nào. Thêm các trường hợp hồi quy bên cạnh các bài kiểm thử Python runtime và Poetry, bao gồm dấu nháy hỗn hợp và cả hai dạng Poetry. Công việc hoàn tất khi các trường hợp nghiệm thu đạt yêu cầu và hành vi hiện có với dấu nháy kép vẫn không thay đổi.

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

Mô tả

bug good first issue
  • Difficulty: small (a few hours)
  • Area: Python scanner
Problem

parsePyprojectToml in src/core-open/scanners/python-scanner.ts only accepts double-quoted TOML strings for the project name, requires-python, and [project] dependencies:

# around lines 1032–1040
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
const pyVerMatch = content.match(/^\s*requires-python\s*=\s*"([^"]+)"/m);
# dependencies array: const lineRegex = /"([^"]+)"/g;

Poetry tables have the same limit (appendPoetryDependencyTable, around line 989): name = "version" and { version = "..." } match only "...".

Single quotes are valid TOML. A project written like this reports no runtime and no dependencies:

[project]
name = 'demo'
requires-python = '>=3.11'
dependencies = [
    'requests>=2.31',
    "flask>=3.0",
]

[project.optional-dependencies] and [dependency-groups] already go through collectQuotedStrings, which accepts both quote styles. Pipfile [requires] was fixed the same way. The [project] block and Poetry tables were not.

Expected behaviour

Single-quoted, double-quoted, and triple-quoted strings are read the same way in [project] and in Poetry dependency tables. A mixed array ('requests>=2.31' next to "flask>=3.0") keeps both packages. Existing double-quoted fixtures stay unchanged.

Acceptance
  • Add tests next to the existing Python / Poetry cases (for example test/python-runtime-pin.test.ts and the Poetry / optional-deps tests).
  • requires-python = '>=3.11' reports Python 3.11 as the runtime.
  • A [project] dependencies array of only single-quoted requirement strings exports those packages from vg scan.
  • A mixed-quote array keeps every entry.
  • Poetry requests = '2.31.0' and requests = { version = '2.31.0' } are read.
  • Double-quoted forms, and a project with no requires-python, behave as they do today.

Ngôn ngữ chính
TypeScript
Star
4
Fork
3
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
76

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

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 vibgrate/cli

Tất cả issue của vibgrate/cli

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.