ruff icon indicating copy to clipboard operation
ruff copied to clipboard

`red-knot`: introduce a `StatisticsRecorder` trait for the `KeyValueCache`

Open AlexWaygood opened this issue 1 year ago • 1 comments
trafficstars

Summary

This PR changes the DebugStatistics and ReleaseStatistics structs so that they implement a common StatisticsRecorder trait, and makes the KeyValueCache struct generic over a type parameter bound to that trait. The advantage of this approach is that it's much harder for the DebugStatistics and ReleaseStatistics structs to accidentally grow out of sync in the methods that they implement, which was the cause of the release-build failure recently fixed in #11177.

Test Plan

cargo test -p red_knot and cargo build --release both continue to pass for me locally

AlexWaygood avatar Apr 27 '24 16:04 AlexWaygood

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

github-actions[bot] avatar Apr 27 '24 16:04 github-actions[bot]

Going to let @MichaReiser confirm if this looks ok.

carljm avatar Apr 29 '24 23:04 carljm