Fix lint and types in scripts/cell_cost.py - #297
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The lint job on
mainis currently failing.scripts/cell_cost.pyis neither black-clean nor mypy-clean:This is my fault, from #292, and the way it slipped through is worth recording:
pre-commit run --all-filesonly 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_reportdeclareddict[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, soAnyis the honest type, and the ignores go away with it.A list of
None. The sequential baseline was: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.--jsonmodes to confirm the behaviour is unchanged: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