MCPcopy Create free account
hub / github.com/astral-sh/ruff / format_diff

Function format_diff

scripts/memory_report.py:100–112  ·  view source on GitHub ↗

Format a difference with percentage and direction indicator.

(*, old_bytes: int, new_bytes: int)

Source from the content-addressed store, hash-verified

98
99
100def format_diff(*, old_bytes: int, new_bytes: int) -> str:
101 """Format a difference with percentage and direction indicator."""
102 diff = new_bytes - old_bytes
103
104 if diff == 0:
105 return "-"
106
107 sign = "+" if diff > 0 else ""
108
109 if old_bytes == 0:
110 return f"{sign}{format_bytes(diff)} (new)"
111
112 return f"{sign}{diff / old_bytes:.2%} ({format_bytes(abs(diff))})"
113
114
115def format_outcome(*, old_bytes: int, new_bytes: int) -> str:

Callers 1

render_summaryFunction · 0.85

Calls 1

format_bytesFunction · 0.85

Tested by

no test coverage detected