From b8311f3002fadf96ade4672179d7a5b9d0385f04 Mon Sep 17 00:00:00 2001 From: leehengpan Date: Tue, 29 Oct 2024 15:48:19 -0400 Subject: [PATCH] formatting --- .../budget_2025/capital_gains_tax_increase.py | 8 +++++++- .../remove_head_of_household.py | 8 +++++++- .../ctc/family_security_act_2024_ctc.py | 8 +++++++- .../eitc/family_security_act_2024_eitc.py | 7 ++++++- .../boost/boost_middle_class_tax_credit.py | 8 +++++++- .../congress/tlaib/end_child_poverty_act.py | 8 +++++++- .../eitc/halve_joint_eitc_phase_out_rate.py | 10 ++++++++-- .../federal/abolish_federal_income_tax.py | 8 +++++++- .../reforms/federal/abolish_payroll_tax.py | 8 +++++++- .../federal/reported_state_income_tax.py | 8 +++++++- .../harris/lift/middle_class_tax_credit.py | 8 +++++++- .../rent_relief_act/rent_relief_tax_credit.py | 8 +++++++- ...ling_status_and_eligibility_by_children.py | 8 +++++++- policyengine_us/reforms/states/dc/dc_ctc.py | 8 +++++++- .../reforms/states/mn/walz/mn_walz_hf1938.py | 8 +++++++- .../ny/wftc/ny_working_families_tax_credit.py | 8 +++++++- .../rebate/or_rebate_state_tax_exempt.py | 7 ++++++- .../treasury/repeal_dependent_exemptions.py | 8 +++++++- policyengine_us/reforms/utils.py | 20 +++++++++++++------ 19 files changed, 139 insertions(+), 25 deletions(-) diff --git a/policyengine_us/reforms/biden/budget_2025/capital_gains_tax_increase.py b/policyengine_us/reforms/biden/budget_2025/capital_gains_tax_increase.py index e47b2e7fb3a..b1a0403cca5 100644 --- a/policyengine_us/reforms/biden/budget_2025/capital_gains_tax_increase.py +++ b/policyengine_us/reforms/biden/budget_2025/capital_gains_tax_increase.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_capital_gains_tax_increase() -> Reform: class capital_gains_tax(Variable): value_type = float @@ -142,7 +143,12 @@ def create_capital_gains_tax_increase_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.biden.budget_2025.capital_gains", "active", create_capital_gains_tax_increase, bypass + parameters, + period, + "gov.contrib.biden.budget_2025.capital_gains", + "active", + create_capital_gains_tax_increase, + bypass, ) diff --git a/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py b/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py index 621c7382c5b..7be868522d9 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py +++ b/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_remove_head_of_household() -> Reform: class reform(Reform): def apply(self): @@ -13,7 +14,12 @@ def create_remove_head_of_household_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.congress.romney.family_security_act", "remove_head_of_household", create_remove_head_of_household, bypass + parameters, + period, + "gov.contrib.congress.romney.family_security_act", + "remove_head_of_household", + create_remove_head_of_household, + bypass, ) diff --git a/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py b/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py index 96c9ad09093..f4e86d7d028 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py +++ b/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_family_security_act_2024_ctc() -> Reform: class ctc_phase_in_rate(Variable): value_type = float @@ -142,7 +143,12 @@ def create_family_security_act_2024_ctc_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.congress.romney.family_security_act_2_0.ctc", "apply_ctc_structure", create_family_security_act_2024_ctc, bypass + parameters, + period, + "gov.contrib.congress.romney.family_security_act_2_0.ctc", + "apply_ctc_structure", + create_family_security_act_2024_ctc, + bypass, ) diff --git a/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py b/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py index e4528dbe62c..eb783170020 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py +++ b/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py @@ -34,7 +34,12 @@ def create_family_security_act_2024_eitc_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.congress.romney.family_security_act_2_0.eitc", "apply_eitc_structure", create_family_security_act_2024_eitc, bypass + parameters, + period, + "gov.contrib.congress.romney.family_security_act_2_0.eitc", + "apply_eitc_structure", + create_family_security_act_2024_eitc, + bypass, ) diff --git a/policyengine_us/reforms/congress/tlaib/boost/boost_middle_class_tax_credit.py b/policyengine_us/reforms/congress/tlaib/boost/boost_middle_class_tax_credit.py index 816b3a50282..6801eb8ed8f 100644 --- a/policyengine_us/reforms/congress/tlaib/boost/boost_middle_class_tax_credit.py +++ b/policyengine_us/reforms/congress/tlaib/boost/boost_middle_class_tax_credit.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_boost_middle_class_tax_credit() -> Reform: class boost_middle_class_tax_credit(Variable): value_type = float @@ -144,7 +145,12 @@ def create_boost_middle_class_tax_credit_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.harris.lift.middle_class_tax_credit", "in_effect", create_boost_middle_class_tax_credit, bypass + parameters, + period, + "gov.contrib.harris.lift.middle_class_tax_credit", + "in_effect", + create_boost_middle_class_tax_credit, + bypass, ) diff --git a/policyengine_us/reforms/congress/tlaib/end_child_poverty_act.py b/policyengine_us/reforms/congress/tlaib/end_child_poverty_act.py index 50d6f2fdb80..55471fee420 100644 --- a/policyengine_us/reforms/congress/tlaib/end_child_poverty_act.py +++ b/policyengine_us/reforms/congress/tlaib/end_child_poverty_act.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_end_child_poverty_act() -> Reform: class ecpa_adult_dependent_credit(Variable): value_type = float @@ -177,7 +178,12 @@ def create_end_child_poverty_act_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.congress.tlaib.end_child_poverty_act", "in_effect", create_end_child_poverty_act, bypass + parameters, + period, + "gov.contrib.congress.tlaib.end_child_poverty_act", + "in_effect", + create_end_child_poverty_act, + bypass, ) diff --git a/policyengine_us/reforms/eitc/halve_joint_eitc_phase_out_rate.py b/policyengine_us/reforms/eitc/halve_joint_eitc_phase_out_rate.py index 4c2cc47d229..d15df003a88 100644 --- a/policyengine_us/reforms/eitc/halve_joint_eitc_phase_out_rate.py +++ b/policyengine_us/reforms/eitc/halve_joint_eitc_phase_out_rate.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_halve_joint_eitc_phase_out_rate() -> Reform: class eitc_phase_out_rate(Variable): value_type = float @@ -27,9 +28,14 @@ def apply(self): def create_halve_joint_eitc_phase_out_rate_reform( parameters, period, bypass: bool = False -): +): return create_reform_if_active( - parameters, period, "gov.contrib.joint_eitc", "in_effect", create_halve_joint_eitc_phase_out_rate, bypass + parameters, + period, + "gov.contrib.joint_eitc", + "in_effect", + create_halve_joint_eitc_phase_out_rate, + bypass, ) diff --git a/policyengine_us/reforms/federal/abolish_federal_income_tax.py b/policyengine_us/reforms/federal/abolish_federal_income_tax.py index 3d814eb9af9..122a0b24712 100644 --- a/policyengine_us/reforms/federal/abolish_federal_income_tax.py +++ b/policyengine_us/reforms/federal/abolish_federal_income_tax.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_abolish_federal_income_tax() -> Reform: class household_tax_before_refundable_credits(Variable): value_type = float @@ -51,7 +52,12 @@ def create_abolish_federal_income_tax_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.ubi_center.flat_tax", "abolish_federal_income_tax", create_abolish_federal_income_tax, bypass + parameters, + period, + "gov.contrib.ubi_center.flat_tax", + "abolish_federal_income_tax", + create_abolish_federal_income_tax, + bypass, ) diff --git a/policyengine_us/reforms/federal/abolish_payroll_tax.py b/policyengine_us/reforms/federal/abolish_payroll_tax.py index 80dc05507f3..40c3d9c5591 100644 --- a/policyengine_us/reforms/federal/abolish_payroll_tax.py +++ b/policyengine_us/reforms/federal/abolish_payroll_tax.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_abolish_payroll_tax() -> Reform: class household_tax_before_refundable_credits(Variable): value_type = float @@ -31,7 +32,12 @@ def create_abolish_payroll_tax_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.ubi_center.flat_tax", "abolish_payroll_tax", create_abolish_payroll_tax, bypass + parameters, + period, + "gov.contrib.ubi_center.flat_tax", + "abolish_payroll_tax", + create_abolish_payroll_tax, + bypass, ) diff --git a/policyengine_us/reforms/federal/reported_state_income_tax.py b/policyengine_us/reforms/federal/reported_state_income_tax.py index 3add0fcbb86..9bd93fd93c2 100644 --- a/policyengine_us/reforms/federal/reported_state_income_tax.py +++ b/policyengine_us/reforms/federal/reported_state_income_tax.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_reported_state_income_tax() -> Reform: class household_tax_before_refundable_credits(Variable): value_type = float @@ -58,7 +59,12 @@ def create_reported_state_income_tax_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "simulation", "reported_state_income_tax", create_reported_state_income_tax, bypass + parameters, + period, + "simulation", + "reported_state_income_tax", + create_reported_state_income_tax, + bypass, ) diff --git a/policyengine_us/reforms/harris/lift/middle_class_tax_credit.py b/policyengine_us/reforms/harris/lift/middle_class_tax_credit.py index 6cf5fc3968f..69f9b95b666 100644 --- a/policyengine_us/reforms/harris/lift/middle_class_tax_credit.py +++ b/policyengine_us/reforms/harris/lift/middle_class_tax_credit.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_middle_class_tax_credit() -> Reform: class middle_class_tax_credit(Variable): value_type = float @@ -58,7 +59,12 @@ def create_middle_class_tax_credit_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.harris.lift.middle_class_tax_credit", "in_effect", create_middle_class_tax_credit, bypass + parameters, + period, + "gov.contrib.harris.lift.middle_class_tax_credit", + "in_effect", + create_middle_class_tax_credit, + bypass, ) diff --git a/policyengine_us/reforms/harris/rent_relief_act/rent_relief_tax_credit.py b/policyengine_us/reforms/harris/rent_relief_act/rent_relief_tax_credit.py index afbda72b360..c722e4f8e10 100644 --- a/policyengine_us/reforms/harris/rent_relief_act/rent_relief_tax_credit.py +++ b/policyengine_us/reforms/harris/rent_relief_act/rent_relief_tax_credit.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_rent_relief_tax_credit() -> Reform: class rent_relief_tax_credit(Variable): value_type = float @@ -78,7 +79,12 @@ def create_rent_relief_tax_credit_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.harris.rent_relief_act.rent_relief_credit", "in_effect", create_rent_relief_tax_credit, bypass + parameters, + period, + "gov.contrib.harris.rent_relief_act.rent_relief_credit", + "in_effect", + create_rent_relief_tax_credit, + bypass, ) diff --git a/policyengine_us/reforms/local/nyc/stc/adjust_income_limit_by_filing_status_and_eligibility_by_children.py b/policyengine_us/reforms/local/nyc/stc/adjust_income_limit_by_filing_status_and_eligibility_by_children.py index c127de28a71..eba9e6d7114 100644 --- a/policyengine_us/reforms/local/nyc/stc/adjust_income_limit_by_filing_status_and_eligibility_by_children.py +++ b/policyengine_us/reforms/local/nyc/stc/adjust_income_limit_by_filing_status_and_eligibility_by_children.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_adjust_income_limit_and_min_children_by_filing_status() -> Reform: class nyc_school_tax_credit_eligible(Variable): value_type = bool @@ -52,7 +53,12 @@ def create_adjust_income_limit_by_filing_status_and_eligibility_by_children_refo parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.local.nyc.stc", "adjust_income_limit_by_filing_status_and_eligibility_by_children", create_adjust_income_limit_and_min_children_by_filing_status, bypass + parameters, + period, + "gov.contrib.local.nyc.stc", + "adjust_income_limit_by_filing_status_and_eligibility_by_children", + create_adjust_income_limit_and_min_children_by_filing_status, + bypass, ) diff --git a/policyengine_us/reforms/states/dc/dc_ctc.py b/policyengine_us/reforms/states/dc/dc_ctc.py index adbd23a9b2f..f2030e81606 100644 --- a/policyengine_us/reforms/states/dc/dc_ctc.py +++ b/policyengine_us/reforms/states/dc/dc_ctc.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_dc_ctc() -> Reform: class dc_ctc(Variable): value_type = float @@ -57,7 +58,12 @@ def apply(self): def create_dc_ctc_reform(parameters, period, bypass: bool = False): return create_reform_if_active( - parameters, period, "gov.contrib.states.dc.ctc", "in_effect", create_dc_ctc, bypass + parameters, + period, + "gov.contrib.states.dc.ctc", + "in_effect", + create_dc_ctc, + bypass, ) diff --git a/policyengine_us/reforms/states/mn/walz/mn_walz_hf1938.py b/policyengine_us/reforms/states/mn/walz/mn_walz_hf1938.py index f62b22ceb6f..21e509ccc00 100644 --- a/policyengine_us/reforms/states/mn/walz/mn_walz_hf1938.py +++ b/policyengine_us/reforms/states/mn/walz/mn_walz_hf1938.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + # Repealing Minnesota Bill HF1938 to pre 2023 rules def create_mn_walz_hf1938_repeal() -> Reform: class mn_refundable_credits(Variable): @@ -209,7 +210,12 @@ def create_mn_walz_hf1938_repeal_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.states.mn.walz.hf1938", "repeal", create_mn_walz_hf1938_repeal, bypass + parameters, + period, + "gov.contrib.states.mn.walz.hf1938", + "repeal", + create_mn_walz_hf1938_repeal, + bypass, ) diff --git a/policyengine_us/reforms/states/ny/wftc/ny_working_families_tax_credit.py b/policyengine_us/reforms/states/ny/wftc/ny_working_families_tax_credit.py index e6cef306bee..9b73387039e 100644 --- a/policyengine_us/reforms/states/ny/wftc/ny_working_families_tax_credit.py +++ b/policyengine_us/reforms/states/ny/wftc/ny_working_families_tax_credit.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_ny_working_families_tax_credit() -> Reform: class ny_working_families_tax_credit(Variable): value_type = float @@ -527,7 +528,12 @@ def create_ny_working_families_tax_credit_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.states.ny.wftc", "in_effect", create_ny_working_families_tax_credit, bypass + parameters, + period, + "gov.contrib.states.ny.wftc", + "in_effect", + create_ny_working_families_tax_credit, + bypass, ) diff --git a/policyengine_us/reforms/states/oregon/rebate/or_rebate_state_tax_exempt.py b/policyengine_us/reforms/states/oregon/rebate/or_rebate_state_tax_exempt.py index f42d89c3ca4..b2d859a243b 100644 --- a/policyengine_us/reforms/states/oregon/rebate/or_rebate_state_tax_exempt.py +++ b/policyengine_us/reforms/states/oregon/rebate/or_rebate_state_tax_exempt.py @@ -47,7 +47,12 @@ def create_or_rebate_state_tax_exempt_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.states.or.rebate", "state_tax_exempt", create_or_rebate_state_tax_exempt, bypass + parameters, + period, + "gov.contrib.states.or.rebate", + "state_tax_exempt", + create_or_rebate_state_tax_exempt, + bypass, ) diff --git a/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py b/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py index 8f7fae7e93a..221bed2cb88 100644 --- a/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py +++ b/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py @@ -1,6 +1,7 @@ from policyengine_us.model_api import * from policyengine_us.reforms.utils import create_reform_if_active + def create_repeal_dependent_exemptions() -> Reform: class exemptions_count(Variable): value_type = int @@ -25,7 +26,12 @@ def create_repeal_dependent_exemptions_reform( parameters, period, bypass: bool = False ): return create_reform_if_active( - parameters, period, "gov.contrib.treasury", "repeal_dependent_exemptions", create_repeal_dependent_exemptions, bypass + parameters, + period, + "gov.contrib.treasury", + "repeal_dependent_exemptions", + create_repeal_dependent_exemptions, + bypass, ) diff --git a/policyengine_us/reforms/utils.py b/policyengine_us/reforms/utils.py index 888c4912124..9195c341854 100644 --- a/policyengine_us/reforms/utils.py +++ b/policyengine_us/reforms/utils.py @@ -1,9 +1,17 @@ from policyengine_core.periods import period as period_ -def create_reform_if_active(parameters, period, parameter_path: str, active_parameter_path: str, reform_function, bypass: bool = False) -> bool: + +def create_reform_if_active( + parameters, + period, + parameter_path: str, + active_parameter_path: str, + reform_function, + bypass: bool = False, +) -> bool: """ Check if a reform parameter is active in any of the next 5 years. - + Args: parameters: PolicyEngine parameters object period: Current period @@ -15,17 +23,17 @@ def create_reform_if_active(parameters, period, parameter_path: str, active_para """ if bypass: return reform_function() - + current_period = period_(period) path_parts = parameter_path.split(".") - + p = parameters for part in path_parts: p = getattr(p, part) - + for _ in range(5): if getattr(p(current_period), active_parameter_path): return reform_function() current_period = current_period.offset(1, "year") - + return None