Skip to content

Commit 32c2f1e

Browse files
Kasper JungeRalphify
authored andcommitted
workspace: record text alias inline in collect_output
Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent ce487d3 commit 32c2f1e

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

workspace/ralphs/improve-codebase/backlog.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ the handful of remaining single-site `2`s are flagged below with
8484
`_output.py:format_duration` into the `if minutes < _MINUTES_PER_HOUR:`
8585
branch. Saved a modulo on every duration ≥ 1h and co-located the
8686
local with its only use site.)
87-
- `_output.py:collect_output` has `text = ensure_str(stream)` then
88-
`parts.append(text)` one line later. Same alias-inline shape as
89-
fc5e1cb / 497c028 / 52e0272 — single use, helper name already
90-
documents intent. Small but consistent Phase 4 candidate.
87+
- (ce487d3 — inlined `text = ensure_str(stream)` in
88+
`_output.py:collect_output`. Same alias-inline shape as fc5e1cb /
89+
497c028 / 52e0272. Helper name `ensure_str` already documents the
90+
decode step, so the intermediate binding added no clarity.)
9191
- (d0060b3 — exposed `_LivePanelBase.outcome` as a public property and
9292
switched `_FullscreenPeek._build_header`'s `source._outcome` read to
9393
go through it. Mirror of ef9a178's `iteration_id` cleanup.) Two

workspace/ralphs/improve-codebase/coverage/_output.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# `_output.py` coverage
22

3-
Valid at: 7730dd4
3+
Valid at: ce487d3
44

55
## Recent changes
66

7+
- ce487d3 — inlined `text = ensure_str(stream)` in `collect_output`.
8+
The local was assigned then read exactly once on the next line as
9+
`parts.append(text)`. The `ensure_str` helper name already
10+
documents the decode step, so the intermediate binding was pure
11+
noise. Same alias-inline shape as fc5e1cb / 497c028 / 52e0272.
712
- 7730dd4 — narrowed `secs = total % _SECONDS_PER_MINUTE` scope in
813
`format_duration`. The local was computed unconditionally between
914
the `total = int(seconds + 0.5)` / `minutes = total // 60` setup and
@@ -34,12 +39,6 @@ Valid at: 7730dd4
3439
Could lift to a `_format_millions(n)` helper, but each site is one
3540
line and the duplication is intentional (the rounding guard explains
3641
the second site). Skip unless a third user appears.
37-
- `collect_output`'s `text = ensure_str(stream)` local is read once on
38-
the next line (`parts.append(text)`). Could inline as
39-
`parts.append(ensure_str(stream))` for the same alias-inline pattern
40-
as fc5e1cb / 497c028 / 52e0272. Tradeoff: the local documents the
41-
decoded form, but `ensure_str` already names the operation. Worth
42-
a Phase 4 iteration if we want symmetry with the other inlines.
4342
- The two `format_*` functions both have a "rounded value crossed into
4443
next unit" guard (59.95s → "1m 0s"; 999_950 → "1.0M") with parallel
4544
comments referencing each other. Already kept in lockstep — no

workspace/ralphs/improve-codebase/iterations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
One line per iteration: `<sha> <summary>`.
44

5+
ce487d3 refactor: inline `text` alias in `_output.py:collect_output` — the local was assigned from `ensure_str(stream)` and read exactly once on the next line as `parts.append(text)`. Same alias-inline shape as fc5e1cb / 497c028 / 52e0272 — the `ensure_str` helper name already documents the decode step, so the intermediate binding was pure noise. Tests in `test_output.py` cover the str, bytes, and stdout+stderr-newline-join paths.
6+
57
7730dd4 refactor: narrow `secs = total % _SECONDS_PER_MINUTE` scope into the `if minutes < _MINUTES_PER_HOUR:` branch in `_output.py:format_duration` — the local was computed unconditionally but only consumed by `f"{minutes}m {secs}s"` on the truthy branch. The hours branch derives `hours`/`mins` independently and never references `secs`, so the modulo was wasted work for any duration ≥ 1h. Same Phase 4 narrow-the-scope shape as 134078d (`name_col`), ef176bf (`line_count`), 59b0e34 (`page`), b19625e (`new_offset`). Tests in test_output.py cover both branches (sub-hour: lines 110–137; hour+: lines 140–144), so the move is pinned in either direction.
68

79
d0060b3 refactor: replace `source._outcome` cross-class access with public `outcome` property on `_LivePanelBase` — `_FullscreenPeek._build_header` was reading the private attribute directly on its `source` panel. Added an `@property outcome` that returns `self._outcome`, matching the `iteration_id` property pattern from ef9a178 (which cleaned up the parallel `_fullscreen_view._iteration_id` cross-class access). The two remaining cross-class private reads on `_LivePanelBase` (`source._scroll_lines` at lines 750 and 872) read a mutable list that's also appended to from within the class, so a read-only property would mask the asymmetry — leaving those alone until a real need appears. Same observable behavior — `_outcome` is still the single source of truth written by `freeze`, and all existing readers get the same value. The direct `panel_before._outcome == "completed"` assertion in test_console_emitter.py:1766 still passes (underlying attribute is unchanged); fullscreen-header rendering paths exercise the new property transitively.

0 commit comments

Comments
 (0)