REQ: Support ruamel.yaml's RoundTripLoader/Dumper for retaining comments
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 32/100
Hướng nghiên cứu
Bắt đầu trong box/box.py, tại phần mã constructor được liên kết trong issue, sau đó lần theo cách from_yaml và to_yaml xử lý ruamel.yaml RoundTripLoader, RoundTripDumper và CommentedMap. Xác nhận dữ liệu được chuyển đổi thành các đối tượng Box và được tuần tự hóa như thế nào. Được xem là hoàn tất khi các comment và thứ tự YAML vẫn được giữ nguyên qua một chu kỳ load/dot-notation/use/dump.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Now that the default YAML library is ruamel.yaml, and its notable feature is round trip comment preservation, my expectation is that this should work:
In [1]: from box import Box
In [2]: yaml_doc = """---
...: # This is my YAML doc
...: zlast: 1 # This is a line comment on zlast
...: afirst: 2 # This should be shown second, not first!"""
In [3]: mybox = Box.from_yaml(yaml_doc)
In [4]: print(mybox.to_yaml())
afirst: 2
zlast: 1
Unordered, and no comments! However ruamel.yaml has RoundTripLoader and RoundTripDumper available!
In [8]: import ruamel.yaml as yaml
In [9]: data = yaml.load(yaml_doc, Loader=yaml.RoundTripLoader)
In [10]: print(yaml.dump(data, Dumper=yaml.RoundTripDumper))
# This is my YAML doc
zlast: 1 # This is a line comment on zlast
afirst: 2 # This should be shown second, not first!
But using them with Box only helps resolve the creation order issue -- the comments are gone:
In [11]: mybox = Box.from_yaml(yaml_doc, Loader=yaml.RoundTripLoader)
In [11]: print(mybox.to_yaml(Dumper=yaml.RoundTripDumper))
zlast: 1
afirst: 2
Naturally -- as the incoming data is unrolled into a Box in the constructor:
https://github.com/cdgriffith/Box/blob/4a505124686c1f0b79ea84bb292aec331ee70f51/box/box.py#L223
I'm not sure if there's reasonable way for Box to coexist with the ruamel.yaml.CommentedMap, but it would be VERY convenient to work with my YAML files in box dot notation, while leaving the human readable comments intact.
- Ngôn ngữ chính
- Python
- Star
- 2.8k
- Fork
- 145
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cdgriffith/Box
-
subclass of `Box` does not unpickle correctlyCó thể đã có người làm @koriyoshi2041 đã nhận 143 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
cdgriffith/Box#308 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
cdgriffith/Box#307 · 1 bình luận ·
-
Dotted keys read from YAML are lost with box_dots / default_boxCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
cdgriffith/Box#305 ·
-
[Bug] Camel killer box and box dots gives unexpected behaviourCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
cdgriffith/Box#300 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
cdgriffith/Box#298 ·
Tất cả issue của cdgriffith/Box
Issue tương tự
-
good first issue tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Commits pushed after #1095 merged did not land (ahmi/unified-nova-mcp-review-e095 @ 80fa23a)Đang mởbug deferred domain:ci P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
get_page_thumbnail modifies cached page images, affecting later thumbnails and picture exportsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
docling-project/docling-mcp#147 ·
-
issue: A pipe model's Valves button ignores the Allow Chat Valves permissionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-webui/open-webui#32771 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Scheduled Security Scan is failing on mainCó thể đã có người làm @pkupt đã nhận hôm nay. Đang mởsecurity-scan-failure
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 74/100
semantica-agi/semantica#2045 ·
Maintainer thường phản hồi trong vòng 2 ngày