Repository navigation
Clear all 6 mypy errors in llm_recorder.py (#432 session 12) - #458
Merged
Merged
Conversation
_build_markdown() is one large function (~1100 lines), and three
short-lived local variable names got reused across unrelated blocks
within its single scope, each time colliding with a type already
established for that name elsewhere in the function:
- `s` at line 809 (Optional[Dict[str, Any]] from file_map.get(p))
collided with the `for s in parsed_files` convention (non-Optional
Dict[str, Any]) used throughout the rest of the function. Renamed
to `matched_file` at its point of use.
- `struct_hits` at line 1081 (List[Tuple[str, int]]) collided with
an earlier `struct_hits: List[str]` accumulator at line 924.
Renamed to `struct_signal_hits`. This is also what caused the
"Unpacking a string is disallowed" error a few lines down --
`for k, v in struct_hits[:4]` was unpacking the OLD List[str]
binding, not the tuple list actually being built here.
- `p = file_data.get("path")` (line 1411) was missing the default
every other `.get("path", ...)` call in this file supplies,
meaning a parsed_files entry with no "path" key would silently
produce `p = None`, later crashing `Path(p).name` with a
TypeError. Added the same `""` default used at line 91/107.
Baseline: 41 -> 35 unique entries.
Contributor
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.
Summary
Session 12 of the mypy cleanup epic (#432).
_build_markdown()is one large function (~1100 lines), and three short-lived local variable names got reused across unrelated blocks within its single scope, each colliding with a type already established for that name elsewhere in the function:sat line 809 (Optional[Dict[str, Any]]fromfile_map.get(p)) collided with thefor s in parsed_filesconvention (non-OptionalDict[str, Any]) used throughout the rest of the function. Renamed tomatched_fileat its point of use.struct_hitsat line 1081 (List[Tuple[str, int]]) collided with an earlierstruct_hits: List[str]accumulator at line 924. Renamed tostruct_signal_hits. This is also what caused the "Unpacking a string is disallowed" error a few lines down --for k, v in struct_hits[:4]was unpacking the oldList[str]binding, not the tuple list actually being built at that point.p = file_data.get("path")(line 1411) was missing the default every other.get("path", ...)call in this file supplies. Aparsed_filesentry with no"path"key would silently producep = None, later crashingPath(p).namewith aTypeError. Added the same""default used at lines 91/107 -- a genuine latent-bug fix, not cosmetic.Baseline: 41 -> 35 unique entries.
Test plan
mypy gitgalaxy/ --ignore-missing-imports(fresh.mypy_cache) in the CI-matching minimal venv: all 6 errors resolved, no fan-out regressions elsewherepython tests/mypy_audit.py --ci: passes against the regenerated 35-entry baselineflake8 . --count --select=E9,F63,F7,F82: 0python tests/dead_key_audit.py --ci: no new findingspytest tests/ -qin the full-precision venv: run in progress, will confirm green before merge🤖 Generated with Claude Code