Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

out of order sections causing issues

Đang mở
#196 5 bình luận 1 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với mã trong reproducer.py ở issue và chạy nó với TOML được hiển thị; so sánh _insert_after, value_insert_after() và content.value. Theo dõi cách các section không theo thứ tự và bảng build-system được biểu diễn; hoàn thành khi việc chèn section group tạo ra TOML như dự định mà không có bất kỳ AttributeError nào.

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

Mô tả

When there are sections defined out of order, it seems tomlkit does not like it. Original issue was reported at https://github.com/python-poetry/poetry/issues/4718.

The following code runs without issues, however does not modify the toml. Using content.value_insert_after() causes AttributeError: 'dict' object has no attribute '_insert_after'.

If we remove build-system from the toml, the code below raises AttributeError: 'Table' object has no attribute '_insert_after'. However using content.value succeeds with the right results.

reproducer.py

import tomlkit


TOML = tomlkit.parse("""\
[tool.poetry]
name = "foobar"
version = "0.1.0"
description = ""
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins]
""")


if __name__ == '__main__':
    content = TOML["tool"]["poetry"]
    content._insert_after("dependencies", "group", tomlkit.table(is_super_table=True))
    content["group"]["one"] = tomlkit.table(is_super_table=True)
    content["group"]["one"]["dependencies"] = tomlkit.table()
    print(TOML.as_string())

Ngôn ngữ chính
Python
Star
850
Fork
163
Merge trung bình
13 phút
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 python-poetry/tomlkit

Tất cả issue của python-poetry/tomlkit

Issue tương tự

Thêm issue về Python

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.