Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

Summary

  • Adds select_filing_status_value() utility function to simplify filing status selection
  • Uses SINGLE as default (per IRS SOI data showing it's the most common status)
  • Demonstrates pattern with 5 state income tax files

Changes

New utility function in tools/general.py

def select_filing_status_value(filing_status, filing_status_values, input_value=None, **kwargs):
    """Select a value based on filing status, with SINGLE as the default."""

Files refactored to use the utility (first batch)

State File Lines saved
MD md_income_tax_before_credits.py ~12
CA ca_income_tax_before_credits.py ~14
NY ny_main_income_tax.py ~16
AL al_income_tax_before_non_refundable_credits.py ~14
GA ga_income_tax_before_non_refundable_credits.py ~12

Before

return select(
    [
        filing_status == statuses.SINGLE,
        filing_status == statuses.SEPARATE,
        filing_status == statuses.JOINT,
        filing_status == statuses.SURVIVING_SPOUSE,
        filing_status == statuses.HEAD_OF_HOUSEHOLD,
    ],
    [
        p.single.calc(taxable_income),
        p.separate.calc(taxable_income),
        p.joint.calc(taxable_income),
        p.surviving_spouse.calc(taxable_income),
        p.head_of_household.calc(taxable_income),
    ],
)

After

return select_filing_status_value(filing_status, p, taxable_income)

Test plan

  • Added test file test_filing_status_utility.yaml with MD income tax tests
  • Tests single, joint, and head of household filing statuses

Follow-up work

~40 additional state tax files can be migrated to use this utility in follow-up PRs.

Relates to #1176
Extracted from #6286

🤖 Generated with Claude Code

Introduces a new utility function for selecting values based on filing status,
with SINGLE as the default (per IRS SOI data showing it's the most common status).

This PR demonstrates the pattern with 5 state income tax files:
- MD: md_income_tax_before_credits.py
- CA: ca_income_tax_before_credits.py
- NY: ny_main_income_tax.py
- AL: al_income_tax_before_non_refundable_credits.py
- GA: ga_income_tax_before_non_refundable_credits.py

Benefits:
- Reduces boilerplate select() statements from ~15 lines to 1 line
- Makes filing status selection consistent across the codebase
- SINGLE as default improves performance (most common status)

The remaining ~40 state tax files can be migrated in follow-up PRs.

Relates to #1176

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7e781d3) to head (19835f5).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #7243    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           12         5     -7     
  Lines          205        76   -129     
  Branches         0         1     +1     
==========================================
- Hits           205        76   -129     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the simplification. Question: does this only work with scale parameters (single amounts, marginal rates)? If not, can we have an example of a select function without a scale parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants