Skip to content

Fix lint and types in scripts/cell_cost.py - #297

Merged
seanwevans merged 1 commit into
mainfrom
claude/festive-johnson-fd03cl-cell-cost-lint
Sep 17, 2026
Merged

seanwevans merged 1 commit into
mainfrom
claude/festive-johnson-fd03cl-cell-cost-lint

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

The lint job on main is currently failing. scripts/cell_cost.py is neither black-clean nor mypy-clean:

$ black --check scripts/cell_cost.py
1 file would be reformatted.
$ mypy scripts/cell_cost.py
Found 7 errors in 1 file

This is my fault, from #292, and the way it slipped through is worth recording: pre-commit run --all-files only checks files git tracks. The script was still untracked when I ran the hooks before committing, so black and mypy never saw it and reported a clean run on a file they had skipped. I took that as verification. It wasn't.

The fixes

Two of the mypy errors were real defects, not missing annotations:

Values typed as object. build_report / measure_lifecycle / print_report declared dict[str, object], which makes every read of the report an error at the use site — and those errors were being silenced with per-line # type: ignore[index] / [union-attr] comments. They are heterogeneous mappings, so Any is the honest type, and the ignores go away with it.

A list of None. The sequential baseline was:

sequential = time_ms(lambda: [exec(CPU_WORK, {}) for _ in range(workers)])

building a list from a function that returns nothing. Replaced with a loop, which is what it meant.

The rest is black reformatting of three over-long lines.

Testing

  • pre-commit run --all-files: isort, black, pylint, flake8, mypy all pass.
  • tests/test_cell_cost.py: 6 passed.
  • Ran the script on free-threaded 3.14 in both table and --json modes to confirm the behaviour is unchanged:
import surface           create+exec     close    RSS/cell
                              p50 ms    p50 ms         KiB
bare                           11.30      4.03        3662
json/re/dataclasses            31.45      8.37        7754
typical stdlib                 62.40     15.16       13584
dispatch onto warm cell         0.847
fork() of warm parent          1.229
parallel scaling at 4 workers:  threads 3.16x   cells 3.78x

Worth merging before anything else in flight, since every other PR's lint job inherits this failure.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fs1hTtmF4Hm9h617AG9Gse


Generated by Claude Code

The lint job on main is failing: scripts/cell_cost.py is neither black-clean
nor mypy-clean.

It reached main that way because `pre-commit run --all-files` only checks files
git tracks, and the script was still untracked when it was checked before
#292 was committed. Black and mypy never saw it, so the hooks reported a clean
run on a file they had skipped.

Two real defects behind the mypy errors, not just annotations:

* build_report/measure_lifecycle/print_report typed their values as ``object``,
  which makes every read of the report an error at the use site and was being
  silenced with per-line ``type: ignore`` comments. They are heterogeneous
  mappings; ``Any`` is the honest type, and the ignores are gone with it.

* The sequential baseline was ``time_ms(lambda: [exec(...) for _ in range(n)])``
  -- building a list of ``None`` from a function that returns nothing. Replaced
  with a loop, which is also what it meant.

Verified by running the script on free-threaded 3.14 in both table and --json
modes, and by the existing tests/test_cell_cost.py.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fs1hTtmF4Hm9h617AG9Gse
@seanwevans
seanwevans merged commit 32c2b75 into main Sep 17, 2026
10 of 22 checks passed
@seanwevans
seanwevans deleted the claude/festive-johnson-fd03cl-cell-cost-lint branch September 17, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants