Fix code-health regressions in AR SRA and WA WCCC#8537
Merged
Conversation
Two code-health tests started failing on main after PRs PolicyEngine#8324 (AR SRA) and PolicyEngine#8208 (WA WCCC) merged. Neither was caught by the originating PRs' CI because the tests were added later. Both fixes are localized. 1. ar_sra_countable_income.py — `test_no_builtin_sum_over_entity_calls` flagged line 21: per_person_income = sum(person(source, period) for source in p.income.sources) The built-in `sum()` walks an AST containing direct `person(...)` calls, which can break vectorization. Precompute the per-person arrays into a list, then sum the list (the AST under the `sum()` call no longer contains entity-variable calls). 2. wa_wccc_provider_type.py — `test_input_variable_definitions ::test_input_variables_do_not_use_non_geographic_defined_for` flagged this input variable's `defined_for = "wa_wccc_eligible_child"`. Non-geographic `defined_for` on an input variable silently zeros user-provided inputs in surprising ways. Replace with the standard geographic `defined_for = StateCode.WA`, matching every other wa_wccc_* variable. Downstream consumers (e.g., wa_wccc_max_monthly_reimbursement, which retains its own eligible-child gate) continue to filter by eligibility, so output behavior is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8537 +/- ##
===========================================
+ Coverage 97.20% 100.00% +2.79%
===========================================
Files 22 2 -20
Lines 358 30 -328
Branches 4 0 -4
===========================================
- Hits 348 30 -318
+ Misses 8 0 -8
+ Partials 2 0 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hua7450
approved these changes
May 28, 2026
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
Two code-health tests started failing on
mainafter recent merges. Both fixes are localized — total diff is 4 changed lines plus a changelog fragment.Failures fixed
test_no_builtin_sum_over_entity_calls— flaggedpolicyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py:21:Built-in `sum()` walking a generator with direct `person(...)` calls can break vectorization. Precompute the per-person arrays into a list first, then `sum()` the list — the AST under the `sum()` call no longer contains entity-variable calls.
test_input_variable_definitions::test_input_variables_do_not_use_non_geographic_defined_for— flagged `policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py` where the input variable had `defined_for = "wa_wccc_eligible_child"`. Non-geographic `defined_for` on an input variable silently zeros user-provided inputs. Replace with the standard `defined_for = StateCode.WA`, matching every other `wa_wccc_*` variable. Downstream consumers (e.g., `wa_wccc_max_monthly_reimbursement`) retain their own eligible-child gates, so output behavior is unchanged.Context
Test plan
🤖 Generated with Claude Code