Stop reusing three variables for two types each - #371
Merged
Conversation
#350's tail: mypy 50 to 45. Ordinary inference debt this time rather than hidden failures, which is itself worth noting --- the earlier batches were not. `cmd_filter` in `_subtract` was built as a filter string and then replaced by the two-element flag list that carries it; `weights_as_list` in `_history` held the results of `split()` and then the floats parsed from them. Both now use a second name, which is also what the code means. The branch test `type(weights) in [int, float]` decides which arm runs but does not narrow for a type checker. It is narrowed with an `isinstance` assert rather than by rewriting the test, because `isinstance` would start accepting `bool`, which `type() in` excludes on purpose. Narrowing for mypy should not quietly widen what the function takes. Verified by hand, since these touch real code paths rather than annotations: `subtract()` renders and writes its file, and `history()` works at its default, with string weights (the split-and-parse path) and with a numeric weight (the narrowed branch). 682 tests pass, 4 skipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Continuing the tail of #350. mypy 50 → 45, 682 tests pass.
Ordinary inference debt this time rather than hidden failures — which is worth saying, because the earlier batches were not.
cmd_filterin_subtractwas built as a filter string and then replaced by the two-element flag list carrying it.weights_as_listin_historyheld the output ofsplit()and then the floats parsed from it.type(weights) in [int, float]decides a branch but does not narrow. Narrowed with anisinstanceassert rather than by rewriting the test:isinstancewould start acceptingbool, whichtype() inexcludes on purpose, and narrowing for a type checker should not quietly widen what a function takes.Verified by hand, since these touch real code paths rather than annotations:
subtract()renders and writes its file, andhistory()works at its default, with string weights, and with a numeric weight.Also found, filed separately
While reading this file I confirmed #370:
motion_mp()raises on its first call, and behind that failure callssave_txtandsave_analysiswith arguments in the wrong slots. Pre-existing onmasterwith a clean tree, not touched here.Remaining after this: 45.
🤖 Generated with Claude Code