`str()` of a style from `Style.update_link()` leaves out the new link once the original has been converted to a string
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
- 78/100
Hướng nghiên cứu
Lỗi nằm trong rich/style.py: update_link() sao chép _style_definition sang Style mới, và __str__ trả về giá trị đã được cache đó khi nó được đặt. Hãy tái hiện lỗi bằng đoạn mã trong issue, sau đó kiểm tra xem bản sao có bắt đầu mà không có định nghĩa đã cache hay không, giống như _add làm. Công việc được coi là xong khi str(style.update_link(...)) phản ánh liên kết mới sau khi đối tượng gốc đã được chuyển thành chuỗi, và có một bài kiểm tra bao phủ cả việc đặt lẫn xóa liên kết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi! I hit this while writing generated tests against Rich. Style.update_link() returns a style with a different link, but str() of it gives the original style's definition if the original was converted to a string first:
from rich.style import Style
style = Style(bold=True)
print("before str():", str(style.update_link("http://x")))
str(style) # caches the definition on the original
print("after str():", str(style.update_link("http://x")))
Output on Rich 15.0.0 and on main (3a109cc):
before str(): bold link http://x
after str(): bold
update_link copies self._style_definition into the new style, and __str__ returns that cached string when it's set, so the copy reports the original's definition. The same happens the other way round: update_link(None) on a linked style that has been converted to a string still shows link ....
I think the copy should start with no cached definition, as _add does. I have a one-line fix with a test and I'm happy to open a PR.
Python 3.13, macOS.
- Ngôn ngữ chính
- Python
- Star
- 57.8k
- Fork
- 2.6k
- Merge trung bình
- 20 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 Textualize/rich
-
Color.parse() raises raw ValueError instead of ColorParseError for an empty rgb(...) componentĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Textualize/rich#4269 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Textualize/rich#4268 ·
-
Needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Textualize/rich#4267 ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Textualize/rich#4266 ·
-
[BUG] `Text.right_crop(0)` empties the text and an amount larger than the text makes `len()` raiseĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Textualize/rich#4265 ·
Tất cả issue của Textualize/rich
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mohanraj00/entelos#200 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dead url in mise.tomlĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
sweep
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
bketelsen/truenas-mcp#77 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
sandbox-quantum/switch#2163 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
openedx/xblock-lti-consumer#765 ·
Maintainer thường phản hồi trong vòng 1 ngày