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

Function format_diff

scripts/memory_report.py:118–130  ·  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

116
117
118def format_diff(*, old_bytes: int, new_bytes: int) -> str:
119 """Format a difference with percentage and direction indicator."""
120 diff = new_bytes - old_bytes
121
122 if diff == 0:
123 return "-"
124
125 sign = "+" if diff > 0 else ""
126
127 if old_bytes == 0:
128 return f"{sign}{format_bytes(diff)} (new)"
129
130 return f"{sign}{diff / old_bytes:.2%} ({format_bytes(abs(diff))})"
131
132
133def 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