Repository navigation
Clear all 14 mypy errors in galaxyscope.py (#431 session 2) - #438
Merged
Merged
Conversation
Four distinct fixes:
- _process_file_worker's `observation` dict: un-annotated literal dict
with 4 initial str/dict-valued keys, but later code paths assign
float/None values into it too. Annotated as Dict[str, Any] (matching
the function's own declared return type) instead of leaving mypy to
infer a narrow type from the literal's first 4 keys. Resolved 10 of
the 14 -- the "Collection[str]"-family fan-out this session's errors
were mostly made of.
- `import importlib` without `import importlib.util`: worked at runtime
only because something else transitively imported importlib.util
first. Changed to `import importlib.util` directly.
- `self.neighborhood_tracker = defaultdict(int)`: mypy can't infer a key
type from an empty defaultdict. Annotated DefaultDict[str, int],
matching how it's actually keyed (str(path_obj.parent)).
- `run_xray_audit`/`run_firewall_audit`'s `config: Optional[ResolvedConfig]`
signatures: both functions' own docstrings already documented that the
caller may hand over either a ResolvedConfig or a plain dict ("only
.get() works uniformly across both") -- the signature just never said
so. Broadened to Optional[Union[ResolvedConfig, Dict[str, Any]]] in
both binary_anomaly_detector.py and supply_chain_firewall.py to match
the already-intentional, already-documented behavior; galaxyscope.py's
call site (passing self.config, a plain dict) was correct as-is.
187 -> 173 unique baseline entries. Baseline regenerated in the same
minimal environment mypy-audit.yml uses (mypy + PyYAML only), per the
docstring note added after #436's environment mismatch.
Verified: galaxyscope.py, binary_anomaly_detector.py, and
supply_chain_firewall.py all report zero mypy errors after this change.
flake8, dead_key_audit.py --ci, and full pytest suite (866 passed,
1 deselected, 1 pre-existing xfail) all clean.
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
Part of #429/#431, one file per session. This session: `galaxyscope.py` (plus two small signature fixes it depends on).
Four distinct fixes:
187 → 173 unique baseline entries.
Test plan