Fix EG308 false positives and validate issue #87 against interview corpus - #88
Merged
Merged
Conversation
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.
Fix
Closes #87.
EG308 now finds actual Python reads using the AST. A variable mentioned only in
a comment, string literal, or assignment target no longer triggers an unmatched
guard error. Attribute and subscript expressions, f-string interpolation, and
augmented assignments remain covered. Findings point to the first unguarded
read, and subscript matching tolerates quote and whitespace differences.
The proposed EG416 suppression is intentionally not included. Upstream
docassemble's attachment parser
does not consume attachment-level
if:orhide if:keys. Those keys do notensure that content is conditionally generated, so suppressing EG416 would hide
a potential runtime error. Regression tests retain the warning for these cases.
Existing Mako guard and
skip undefinedhandling is unchanged.Validation
pytest -q tests: 391 passed, 54 subtests passed, including 54 new regression cases.mypy src tests --explicit-package-bases: passed (21 source files).git diff --check: passed./home/quinten/all_interviews:.venv/bin/python -m dayamlchecker /home/quinten/all_interviews --no-url-check.This covered 180 YAML files across 54 repositories, with default related
DOCX and Python-module checks. URL checks were disabled to exclude network
variability. The corpus was not modified.
No regressions observed: all changes were expected EG308 corrections.
Inspected all six removed findings: five were assignment targets supplying
defaults in MA209AProtectiveOrder, and one was a commented-out reference.
Four retained findings now point to actual reads rather than earlier assignment
targets (CLACareTypeFinder: 174→177, 175→181, 396→398;
MA209AProtectiveOrder/209A_page_1.yml: 859→862). Every other finding and stderr
were unchanged. Both corpus runs exited 1 because of existing corpus errors.
Unrestricted pytest discovery also picked up an unrelated, ignored ALWeaver
checkout under
workdir/that requires unavailable docassemble dependencies;the complete DAYamlChecker suite was run explicitly from
tests/.