From 7f028e907f3a2067725874478be48a3e1a573bd3 Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Thu, 28 May 2026 10:22:37 -0400 Subject: [PATCH] Fix two code-health regressions in recently merged programs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two code-health tests started failing on main after PRs #8324 (AR SRA) and #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) --- changelog.d/fix-codehealth-ar-sra-wa-wccc.fixed.md | 1 + .../states/ar/ade/oec/sra/income/ar_sra_countable_income.py | 3 ++- .../gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fix-codehealth-ar-sra-wa-wccc.fixed.md diff --git a/changelog.d/fix-codehealth-ar-sra-wa-wccc.fixed.md b/changelog.d/fix-codehealth-ar-sra-wa-wccc.fixed.md new file mode 100644 index 00000000000..43a858bba90 --- /dev/null +++ b/changelog.d/fix-codehealth-ar-sra-wa-wccc.fixed.md @@ -0,0 +1 @@ +Fixed two code-health regressions on main: precompute per-person arrays in `ar_sra_countable_income` (replaces `sum()` over an entity-variable generator), and switch `wa_wccc_provider_type.defined_for` from `"wa_wccc_eligible_child"` to `StateCode.WA` so an input variable no longer carries a non-geographic gate. diff --git a/policyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py b/policyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py index dbeb694537a..9289b238bb9 100644 --- a/policyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py +++ b/policyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py @@ -18,5 +18,6 @@ def formula(spm_unit, period, parameters): # FSU §4.3.2 excludes children's SSI and Social Security; mask by adult status. person = spm_unit.members is_adult = person("age", period.this_year) >= p.eligibility.adult_age_threshold - per_person_income = sum(person(source, period) for source in p.income.sources) + per_person_components = [person(source, period) for source in p.income.sources] + per_person_income = sum(per_person_components) return spm_unit.sum(per_person_income * is_adult) diff --git a/policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py b/policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py index 46866f2ea60..284b719f468 100644 --- a/policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py +++ b/policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py @@ -17,7 +17,7 @@ class wa_wccc_provider_type(Variable): default_value = WAWCCCProviderType.CENTER definition_period = MONTH label = "Washington WCCC child care provider type" - defined_for = "wa_wccc_eligible_child" + defined_for = StateCode.WA reference = ( "https://app.leg.wa.gov/wac/default.aspx?cite=110-15-0200", "https://app.leg.wa.gov/wac/default.aspx?cite=110-15-0205",