`str()` of a style from `Style.update_link()` leaves out the new link once the original has been converted to a string
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
El error está en rich/style.py: update_link() copia _style_definition en el nuevo Style, y __str__ devuelve ese valor en caché cuando está establecido. Reproduce el problema con el fragmento del issue y luego comprueba que la copia empiece sin definición en caché, como lo hace _add. Está terminado cuando str(style.update_link(...)) refleja el nuevo enlace después de que el original se haya convertido a cadena, y una prueba cubre tanto establecer como borrar el enlace.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 57.8k
- Forks
- 2.6k
- Merge medio
- 20 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Textualize/rich
-
Color.parse() raises raw ValueError instead of ColorParseError for an empty rgb(...) componentAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Textualize/rich#4269 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Textualize/rich#4268 ·
-
Needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Textualize/rich#4267 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Textualize/rich#4266 ·
-
[BUG] `Text.right_crop(0)` empties the text and an amount larger than the text makes `len()` raiseAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Textualize/rich#4265 ·
Todos los issues de Textualize/rich
Issues similares
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
sandbox-quantum/switch#2163 ·
Los mantenedores suelen responder en 1 día
-
bug pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pydantic/pydantic-ai#13939 ·
Los mantenedores suelen responder en 1 día
-
priority: low python
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
LearningCircuit/local-deep-research#8849 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
francescopace/espectre#223 ·
Los mantenedores suelen responder en 3 días
-
good first issue Status: Triaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
canonical/imagecraft#538 · 1 comentario ·
Los mantenedores suelen responder en 2 días