Skip to content

Commit

Permalink
fix: support colored >=1.5.0 dependency, close #758
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Negin-Ulster committed Jun 19, 2023
1 parent 530d786 commit 251a653
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/syrupy/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,31 @@ def _is_color_disabled() -> bool:
def _attr(color: Any) -> str:
if _is_color_disabled():
return ""
return colored.attr(color)
try:
return colored.attr(color)
except AttributeError:
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
return colored.style(color) # type: ignore


def _fg(color: Any) -> str:
if _is_color_disabled():
return ""
return colored.fg(color)
try:
return colored.fg(color)
except AttributeError:
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
return colored.fore(color) # type: ignore


def _bg(color: Any) -> str:
if _is_color_disabled():
return ""
return colored.bg(color)
try:
return colored.bg(color)
except AttributeError:
# colored >=1.5.0, see: https://github.com/tophat/syrupy/issues/758
return colored.back(color) # type: ignore


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

1 comment on commit 251a653

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 251a653 Previous: 4466cb4 Ratio
benchmarks/test_1000x.py::test_1000x_reads 0.5989935454559205 iter/sec (stddev: 0.08198145323314139) 0.8513969458346177 iter/sec (stddev: 0.043118684244449756) 1.42
benchmarks/test_1000x.py::test_1000x_writes 0.5939155548889172 iter/sec (stddev: 0.06059942136339333) 0.846072821872911 iter/sec (stddev: 0.04890457963929366) 1.42
benchmarks/test_standard.py::test_standard 0.5723467249426624 iter/sec (stddev: 0.0628510313318419) 0.8189291827513658 iter/sec (stddev: 0.04974762918427435) 1.43

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.