Comment not parsed when value is boolean
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
- 45/100
Hướng nghiên cứu
Bắt đầu với bản tái hiện tomlkit.loads và theo dõi cách các giá trị dưới d["foo"] được tạo, so sánh đường đi boolean với các đường đi integer và string. Hoàn tất khi một giá trị boolean hiển thị được chú thích ở cuối thông qua trivia.comment, khớp với hành vi hiện có và bản tái hiện được cung cấp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I've just tried to set up comment parsing in a TOML config file to see if I could use it for documentation, and it seems like it'll work except for when the configured value is a boolean.
When I drop into a debugger and look at the attributes of the parsed value:
(Pdb) p default_toml[section]
{'CONVERT_TO_PDF': False}
(Pdb) x = default_toml[section]
(Pdb) y = x["CONVERT_TO_PDF"]
and then tab complete to show the attributes, the dict x has a trivia attribute but the value y does not:
(Pdb) p y.
y.__abs__ y.__floor__ y.__invert__ y.__radd__ y.__rpow__ y.__trunc__
y.__add__ y.__floordiv__ y.__le__ y.__rand__ y.__rrshift__ y.__xor__
y.__and__ y.__format__ y.__lshift__ y.__rdivmod__ y.__rshift__ y.as_integer_ratio
y.__bool__ y.__ge__ y.__lt__ y.__reduce__ y.__rsub__ y.bit_length
y.__ceil__ y.__getattribute__ y.__mod__ y.__reduce_ex__ y.__rtruediv__ y.conjugate
y.__class__ y.__getnewargs__ y.__mul__ y.__repr__ y.__rxor__ y.denominator
y.__delattr__ y.__gt__ y.__ne__ y.__rfloordiv__ y.__setattr__ y.from_bytes
y.__dir__ y.__hash__ y.__neg__ y.__rlshift__ y.__sizeof__ y.imag
y.__divmod__ y.__index__ y.__new__ y.__rmod__ y.__str__ y.numerator
y.__doc__ y.__init__ y.__or__ y.__rmul__ y.__sub__ y.real
y.__eq__ y.__init_subclass__ y.__pos__ y.__ror__ y.__subclasshook__ y.to_bytes
y.__float__ y.__int__ y.__pow__ y.__round__ y.__truediv__
- I checked in
x.trivia.commentbut there's nothing there - For other types of value (integer, float and string) comments are expected to be in the
trivia.commentattribute
Is this a bug, or should I be looking for the comment in another place?
To minimally reproduce:
import tomlkit
d = tomlkit.loads("""
[foo]
bar = 1 # hello
baz = false # goodbye
""")
v1 = d["foo"]["bar"]
v2 = d["foo"]["baz"]
print(hasattr(v1, "trivia"))
print(getattr(v1.trivia, "comment"))
print(hasattr(v2, "trivia"))
⇣
True
# hello
False
- 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
- Đọ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 python-poetry/tomlkit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python-poetry/tomlkit#546 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-poetry/tomlkit#603 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
python-poetry/tomlkit#580 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
python-poetry/tomlkit#577 ·
-
Looking for a co-maintainer Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
python-poetry/tomlkit#574 · 5 bình luận ·
Tất cả issue của python-poetry/tomlkit
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100