Skip to content

Commit b11646a

Browse files
MaxGhenisclaude
andauthored
Label hardcoded 2024 dollar targets with literal year 2024 (#791)
etl_national_targets.py previously used a HARDCODED_YEAR = 2024 local constant. Replace it with the literal 2024 everywhere it was read so the year attribution is explicit at every target site and there is no way for a future refactor to accidentally rebind the constant. The warning that fires when the dataset year differs from 2024 is retained. Closes #515 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8090dec commit b11646a

2 files changed

Lines changed: 42 additions & 48 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Label hardcoded 2024 dollar targets in etl_national_targets.py with the literal year 2024 to prevent misattribution if the calibration dataset year changes.

policyengine_us_data/db/etl_national_targets.py

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
5151

5252
tax_benefit_system = CountryTaxBenefitSystem()
5353

54-
# Hardcoded dollar targets are specific to 2024 and should be
55-
# labeled as such. Only CBO/Treasury parameter lookups use the
56-
# dynamic time_period derived from the dataset.
57-
HARDCODED_YEAR = 2024
58-
if time_period != HARDCODED_YEAR:
54+
# Hardcoded dollar targets are specific to 2024 and are labeled as
55+
# `"year": 2024` throughout this file. Only CBO/Treasury parameter
56+
# lookups use the dynamic `time_period` derived from the dataset.
57+
# See issue #515.
58+
if time_period != 2024:
5959
warnings.warn(
60-
f"Dataset year ({time_period}) != HARDCODED_YEAR "
61-
f"({HARDCODED_YEAR}). Hardcoded dollar targets may "
62-
f"be stale and need re-sourcing."
60+
f"Dataset year ({time_period}) != 2024. Hardcoded dollar "
61+
f"targets may be stale and need re-sourcing."
6362
)
6463

6564
# Separate tax-related targets that need filer constraint
@@ -75,39 +74,39 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
7574
"value": 21.247e9,
7675
"source": "Joint Committee on Taxation",
7776
"notes": "SALT deduction tax expenditure",
78-
"year": HARDCODED_YEAR,
77+
"year": 2024,
7978
},
8079
{
8180
"reform_id": 2,
8281
"variable": "medical_expense_deduction",
8382
"value": 11.4e9,
8483
"source": "Joint Committee on Taxation",
8584
"notes": "Medical expense deduction tax expenditure",
86-
"year": HARDCODED_YEAR,
85+
"year": 2024,
8786
},
8887
{
8988
"reform_id": 3,
9089
"variable": "charitable_deduction",
9190
"value": 65.301e9,
9291
"source": "Joint Committee on Taxation",
9392
"notes": "Charitable deduction tax expenditure",
94-
"year": HARDCODED_YEAR,
93+
"year": 2024,
9594
},
9695
{
9796
"reform_id": 4,
9897
"variable": "deductible_mortgage_interest",
9998
"value": 24.8e9,
10099
"source": "Joint Committee on Taxation",
101100
"notes": "Mortgage interest deduction tax expenditure",
102-
"year": HARDCODED_YEAR,
101+
"year": 2024,
103102
},
104103
{
105104
"reform_id": 5,
106105
"variable": "qualified_business_income_deduction",
107106
"value": 63.1e9,
108107
"source": "Joint Committee on Taxation",
109108
"notes": "QBI deduction tax expenditure",
110-
"year": HARDCODED_YEAR,
109+
"year": 2024,
111110
},
112111
]
113112
tax_expenditure_targets = [{**target} for target in raw_tax_expenditure_targets]
@@ -118,111 +117,105 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
118117
"value": 13e9,
119118
"source": "Survey-reported (post-TCJA grandfathered)",
120119
"notes": "Alimony received - survey reported, not tax-filer restricted",
121-
"year": HARDCODED_YEAR,
120+
"year": 2024,
122121
},
123122
{
124123
"variable": "alimony_expense",
125124
"value": 13e9,
126125
"source": "Survey-reported (post-TCJA grandfathered)",
127126
"notes": "Alimony paid - survey reported, not tax-filer restricted",
128-
"year": HARDCODED_YEAR,
127+
"year": 2024,
129128
},
130129
{
131130
"variable": "medicaid",
132131
"value": 871.7e9,
133132
"source": "https://www.cms.gov/files/document/highlights.pdf",
134133
"notes": "CMS 2023 highlights document - total Medicaid spending",
135-
"year": HARDCODED_YEAR,
134+
"year": 2024,
136135
},
137136
{
138137
"variable": "net_worth",
139138
"value": 160e12,
140139
"source": "Federal Reserve SCF",
141140
"notes": "Total household net worth",
142-
"year": HARDCODED_YEAR,
141+
"year": 2024,
143142
},
144143
{
145144
"variable": "health_insurance_premiums_without_medicare_part_b",
146145
"value": 385e9,
147146
"source": "MEPS/NHEA",
148147
"notes": "Health insurance premiums excluding Medicare Part B",
149-
"year": HARDCODED_YEAR,
148+
"year": 2024,
150149
},
151150
{
152151
"variable": "other_medical_expenses",
153152
"value": 278e9,
154153
"source": "MEPS/NHEA",
155154
"notes": "Out-of-pocket medical expenses",
156-
"year": HARDCODED_YEAR,
155+
"year": 2024,
157156
},
158157
{
159158
"variable": "medicare_part_b_premiums",
160-
"value": get_beneficiary_paid_medicare_part_b_premiums_target(
161-
HARDCODED_YEAR
162-
),
163-
"source": get_beneficiary_paid_medicare_part_b_premiums_source(
164-
HARDCODED_YEAR
165-
),
166-
"notes": get_beneficiary_paid_medicare_part_b_premiums_notes(
167-
HARDCODED_YEAR
168-
),
169-
"year": HARDCODED_YEAR,
159+
"value": get_beneficiary_paid_medicare_part_b_premiums_target(2024),
160+
"source": get_beneficiary_paid_medicare_part_b_premiums_source(2024),
161+
"notes": get_beneficiary_paid_medicare_part_b_premiums_notes(2024),
162+
"year": 2024,
170163
},
171164
{
172165
"variable": "over_the_counter_health_expenses",
173166
"value": 72e9,
174167
"source": "Consumer Expenditure Survey",
175168
"notes": "OTC health products and supplies",
176-
"year": HARDCODED_YEAR,
169+
"year": 2024,
177170
},
178171
{
179172
"variable": "child_support_expense",
180173
"value": 33e9,
181174
"source": "Census Bureau",
182175
"notes": "Child support payments",
183-
"year": HARDCODED_YEAR,
176+
"year": 2024,
184177
},
185178
{
186179
"variable": "child_support_received",
187180
"value": 33e9,
188181
"source": "Census Bureau",
189182
"notes": "Child support received",
190-
"year": HARDCODED_YEAR,
183+
"year": 2024,
191184
},
192185
{
193186
"variable": "spm_unit_capped_work_childcare_expenses",
194187
"value": 348e9,
195188
"source": "Census Bureau SPM",
196189
"notes": "Work and childcare expenses for SPM",
197-
"year": HARDCODED_YEAR,
190+
"year": 2024,
198191
},
199192
{
200193
"variable": "spm_unit_capped_housing_subsidy",
201194
"value": 35e9,
202195
"source": "HUD/Census",
203196
"notes": "Housing subsidies",
204-
"year": HARDCODED_YEAR,
197+
"year": 2024,
205198
},
206199
{
207200
"variable": "real_estate_taxes",
208201
"value": 500e9,
209202
"source": "Census Bureau",
210203
"notes": "Property taxes paid",
211-
"year": HARDCODED_YEAR,
204+
"year": 2024,
212205
},
213206
{
214207
"variable": "rent",
215208
"value": 735e9,
216209
"source": "Census Bureau/BLS",
217210
"notes": "Rental payments",
218-
"year": HARDCODED_YEAR,
211+
"year": 2024,
219212
},
220213
{
221214
"variable": "tip_income",
222215
"value": 53.2e9,
223216
"source": "IRS Form W-2 Box 7 statistics",
224217
"notes": "Social security tips uprated 40% to account for underreporting",
225-
"year": HARDCODED_YEAR,
218+
"year": 2024,
226219
},
227220
# SSA benefit-type totals derived from trust fund data and
228221
# SSA fact sheet type shares
@@ -231,28 +224,28 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
231224
"value": 1_060e9,
232225
"source": "https://www.ssa.gov/OACT/STATS/table4a3.html",
233226
"notes": "~73% of total OASDI ($1,452B CBO projection)",
234-
"year": HARDCODED_YEAR,
227+
"year": 2024,
235228
},
236229
{
237230
"variable": "social_security_disability",
238231
"value": 148e9,
239232
"source": "https://www.ssa.gov/OACT/STATS/table4a3.html",
240233
"notes": "~10.2% of total OASDI (disabled workers)",
241-
"year": HARDCODED_YEAR,
234+
"year": 2024,
242235
},
243236
{
244237
"variable": "social_security_survivors",
245238
"value": 160e9,
246239
"source": "https://www.ssa.gov/OACT/FACTS/",
247240
"notes": "~11.0% of total OASDI (widows, children of deceased)",
248-
"year": HARDCODED_YEAR,
241+
"year": 2024,
249242
},
250243
{
251244
"variable": "social_security_dependents",
252245
"value": 84e9,
253246
"source": "https://www.ssa.gov/OACT/FACTS/",
254247
"notes": "~5.8% of total OASDI (spouses/children of retired+disabled)",
255-
"year": HARDCODED_YEAR,
248+
"year": 2024,
256249
},
257250
# Retirement contribution targets — see issue #553
258251
{
@@ -266,21 +259,21 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
266259
"notes": RETIREMENT_CONTRIBUTION_TARGETS["traditional_ira_contributions"][
267260
"notes"
268261
],
269-
"year": HARDCODED_YEAR,
262+
"year": 2024,
270263
},
271264
{
272265
"variable": "traditional_401k_contributions",
273266
"value": 482.7e9,
274267
"source": "https://fred.stlouisfed.org/series/Y351RC1A027NBEA",
275268
"notes": "BEA/FRED employee DC deferrals ($567.9B) x 85% traditional share (Vanguard HAS 2024)",
276-
"year": HARDCODED_YEAR,
269+
"year": 2024,
277270
},
278271
{
279272
"variable": "roth_401k_contributions",
280273
"value": 85.2e9,
281274
"source": "https://fred.stlouisfed.org/series/Y351RC1A027NBEA",
282275
"notes": "BEA/FRED employee DC deferrals ($567.9B) x 15% Roth share (Vanguard HAS 2024)",
283-
"year": HARDCODED_YEAR,
276+
"year": 2024,
284277
},
285278
{
286279
"variable": "self_employed_pension_contribution_ald",
@@ -293,7 +286,7 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
293286
"notes": RETIREMENT_CONTRIBUTION_TARGETS[
294287
"self_employed_pension_contribution_ald"
295288
]["notes"],
296-
"year": HARDCODED_YEAR,
289+
"year": 2024,
297290
},
298291
{
299292
"variable": "roth_ira_contributions",
@@ -302,7 +295,7 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
302295
"source"
303296
],
304297
"notes": RETIREMENT_CONTRIBUTION_TARGETS["roth_ira_contributions"]["notes"],
305-
"year": HARDCODED_YEAR,
298+
"year": 2024,
306299
},
307300
]
308301

@@ -314,14 +307,14 @@ def extract_national_targets(year: int = DEFAULT_YEAR):
314307
"person_count": 72_429_055,
315308
"source": "CMS/HHS administrative data",
316309
"notes": "Medicaid enrollment count",
317-
"year": HARDCODED_YEAR,
310+
"year": 2024,
318311
},
319312
{
320313
"constraint_variable": "aca_ptc",
321314
"person_count": 19_743_689,
322315
"source": "CMS marketplace data",
323316
"notes": "ACA Premium Tax Credit recipients",
324-
"year": HARDCODED_YEAR,
317+
"year": 2024,
325318
},
326319
{
327320
"constraint_variable": "spm_unit_energy_subsidy_reported",

0 commit comments

Comments
 (0)