Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -23,8 +23,7 @@ from app import travelodge as tl
|
||||
(101, 100),
|
||||
(102, 100),
|
||||
(103, 105),
|
||||
# Banker's rounding at the exact half-step: 21.5 and 22.5 both round to
|
||||
# 22, i.e. 110p. Documented as an ignored sub-penny discrepancy.
|
||||
# Banker's rounding at the half-step: an accepted sub-penny discrepancy.
|
||||
(107.5, 110),
|
||||
(112.5, 110),
|
||||
# The real use: 1/3 off a rail fare must land on TfL's 5p grid.
|
||||
@@ -37,8 +36,6 @@ def test_round_5p_snaps_to_the_5p_grid(pence, want):
|
||||
|
||||
|
||||
def test_round_5p_returns_an_int():
|
||||
# Fares are integer pence everywhere upstream of the final /100, so this
|
||||
# must not leak a float back into the arithmetic.
|
||||
assert isinstance(tl.round_5p(103.0), int)
|
||||
|
||||
|
||||
@@ -68,8 +65,7 @@ def test_parse_guests(spec, want):
|
||||
|
||||
|
||||
def test_parse_guests_preserves_room_order():
|
||||
# Room order is the rooms[i][...] index in the Travelodge query, so it is
|
||||
# part of the request rather than cosmetic.
|
||||
# Room order is part of the query.
|
||||
assert tl.parse_guests("3+1,1,2+2") == [(3, 1), (1, 0), (2, 2)]
|
||||
|
||||
|
||||
@@ -115,8 +111,6 @@ def test_haversine_km_matches_a_known_london_distance():
|
||||
|
||||
|
||||
def test_haversine_km_one_degree_of_latitude_is_about_111km():
|
||||
# A degree of latitude is the same everywhere, so this pins the radius
|
||||
# constant independently of any London coordinate.
|
||||
assert tl.haversine_km((0.0, 0.0), (1.0, 0.0)) == pytest.approx(111.19, abs=0.05)
|
||||
|
||||
|
||||
@@ -153,8 +147,6 @@ def test_sort_rows_orders_by_total_and_sorts_in_place():
|
||||
|
||||
|
||||
def test_sort_rows_puts_unpriced_rows_last():
|
||||
# An unpriced row must not sort as if it were free, which is what the
|
||||
# `total is None` leading key prevents.
|
||||
rows = [row("unpriced", None, 10.0), row("priced", 99.0, 99.0)]
|
||||
tl.sort_rows(rows)
|
||||
assert [r["code"] for r in rows] == ["priced", "unpriced"]
|
||||
@@ -173,8 +165,6 @@ def test_sort_rows_orders_unpriced_rows_among_themselves_by_room_price():
|
||||
|
||||
|
||||
def test_sort_rows_handles_a_zero_total():
|
||||
# `or 0` collapses a genuine 0.0 total onto the None fallback value, so a
|
||||
# free row must still sort ahead of an unpriced one.
|
||||
rows = [row("unpriced", None, 5.0), row("free", 0.0, 0.0)]
|
||||
tl.sort_rows(rows)
|
||||
assert [r["code"] for r in rows] == ["free", "unpriced"]
|
||||
|
||||
Reference in New Issue
Block a user