File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
- Fix pretty repr for ` collections.deque ` https://github.com/Textualize/rich/pull/2864
16
16
- Thread used in progress.track will exit if an exception occurs in a generator https://github.com/Textualize/rich/pull/3402
17
17
- Progress track thread is now a daemon thread https://github.com/Textualize/rich/pull/3402
18
+ - Fixed cached hash preservation upon clearing meta and links https://github.com/Textualize/rich/issues/2942
18
19
19
20
### Changed
20
21
Original file line number Diff line number Diff line change @@ -663,7 +663,7 @@ def clear_meta_and_links(self) -> "Style":
663
663
style ._set_attributes = self ._set_attributes
664
664
style ._link = None
665
665
style ._link_id = ""
666
- style ._hash = self . _hash
666
+ style ._hash = None
667
667
style ._null = False
668
668
style ._meta = None
669
669
return style
Original file line number Diff line number Diff line change @@ -251,3 +251,17 @@ def test_clear_meta_and_links():
251
251
assert clear_style .bgcolor == Color .parse ("black" )
252
252
assert clear_style .bold
253
253
assert not clear_style .italic
254
+
255
+
256
+ def test_clear_meta_and_links_clears_hash ():
257
+ """Regression test for https://github.com/Textualize/rich/issues/2942."""
258
+
259
+ style = Style .parse ("bold red on black link https://example.org" ) + Style .on (
260
+ click = "CLICK"
261
+ )
262
+ hash (style ) # Force hash caching.
263
+
264
+ assert style ._hash is not None
265
+
266
+ clear_style = style .clear_meta_and_links ()
267
+ assert clear_style ._hash is None
You can’t perform that action at this time.
0 commit comments