Skip to content

Commit 783fc5c

Browse files
authoredJun 19, 2023
fix: support colored >=1.5.0 dependency, close #758 (#760)
* chore(deps): update dev dependencies * fix: support colored >=1.5.0 dependency, close #758
1 parent 4466cb4 commit 783fc5c

File tree

2 files changed

+119
-41
lines changed

2 files changed

+119
-41
lines changed
 

‎poetry.lock

+104-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/syrupy/terminal.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,31 @@ def _is_color_disabled() -> bool:
1616
def _attr(color: Any) -> str:
1717
if _is_color_disabled():
1818
return ""
19-
return colored.attr(color)
19+
try:
20+
return colored.attr(color)
21+
except AttributeError:
22+
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
23+
return colored.style(color) # type: ignore
2024

2125

2226
def _fg(color: Any) -> str:
2327
if _is_color_disabled():
2428
return ""
25-
return colored.fg(color)
29+
try:
30+
return colored.fg(color)
31+
except AttributeError:
32+
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
33+
return colored.fore(color) # type: ignore
2634

2735

2836
def _bg(color: Any) -> str:
2937
if _is_color_disabled():
3038
return ""
31-
return colored.bg(color)
39+
try:
40+
return colored.bg(color)
41+
except AttributeError:
42+
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
43+
return colored.back(color) # type: ignore
3244

3345

3446
def _stylize(text: Union[str, int], *args: Any) -> str:

0 commit comments

Comments
 (0)
Please sign in to comment.