Skip to content

Commit

Permalink
Fix pylint C0121 and C0206 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jan 4, 2025
1 parent 7352558 commit 9c77b54
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ EXCLUDED_PATHS = taxcalc/validation,docs/guide

.PHONY=cstest
cstest:
@-pycodestyle --exclude=$(EXCLUDED_PATHS) .
@-pycodestyle --ignore=W503,W504,E712 --exclude=$(EXCLUDED_PATHS) .
@-pycodestyle --ignore=E501,E121 $(TOPLEVEL_JSON_FILES)
@-pycodestyle --ignore=E501,E121 $(TAXCALC_JSON_FILES)
@-pycodestyle --ignore=E501,E121 $(TESTS_JSON_FILES)
Expand Down
4 changes: 2 additions & 2 deletions extend_tcja.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def main():
# calculate 2025-to-2026 parameters indexing factor
pol = taxcalc.Policy()
pirates = pol.inflation_rates()
ifactor25 = 1.0 + pirates[2025-taxcalc.Policy.JSON_START_YEAR]
ifactor28 = 1.0 + pirates[2028-taxcalc.Policy.JSON_START_YEAR]
ifactor25 = 1.0 + pirates[2025 - taxcalc.Policy.JSON_START_YEAR]
ifactor28 = 1.0 + pirates[2028 - taxcalc.Policy.JSON_START_YEAR]
# specify extend-TCJA-beyond-2025 reform
# ... get 2025 parameter values
year = 2025
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@ def PersonalTaxCredit(MARS, c00100, XTOT, nu18,
# calculate Recovery Rebate Credit from CARES Act 2020 and/or ARPA 2021
if c00100 < RRC_ps[MARS - 1]:
recovery_rebate_credit = RRC_c * XTOT
recovery_rebate_credit += RRC_c_unit[MARS-1] + RRC_c_kids * nu18
recovery_rebate_credit += RRC_c_unit[MARS - 1] + RRC_c_kids * nu18
elif 0 < c00100 < RRC_pe[MARS - 1]:
prt = (
(c00100 - RRC_ps[MARS - 1]) /
Expand Down
8 changes: 8 additions & 0 deletions taxcalc/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,15 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
):
continue
if self._data[param].get("indexed", False):
# pylint: disable=singleton-comparison
to_delete[param] = self.sel[param]["_auto"] == True
# pylint warning message:
# Comparison 'self.sel[param]['_auto'] == True' should
# be 'self.sel[param]['_auto'] is True' if checking for
# the singleton value True, or
# 'bool(self.sel[param]['_auto'])' if testing for
# truthiness
# pylint: enable=singleton-comparison
needs_reset.append(param)

self.delete(to_delete, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def parameter_list():
Policy.DEFAULTS_FILE_PATH,
Policy.DEFAULTS_FILE_NAME
)
with open(path, 'r', encoding='utf-8') as f:
with open(path, 'r', encoding='utf-8') as f:
defaults = json.loads(f.read()) # pylint: disable=protected-access
return [k for k in defaults if k != "schema"]

Expand Down
4 changes: 2 additions & 2 deletions taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,8 @@ def test_two_sets_of_tax_brackets():
Test that II_brk? and PT_brk? values are the same under current law.
"""
pol = Policy()
brackets = range(1, 7+1)
years = range(Policy.JSON_START_YEAR, Policy.LAST_KNOWN_YEAR+1)
brackets = range(1, 7 + 1)
years = range(Policy.JSON_START_YEAR, Policy.LAST_KNOWN_YEAR + 1)
emsg = ''
for year in years:
pol.set_year(year)
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/tests/test_puf_var_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_base_table(test_path):
read_vars = list(records_varinfo.USABLE_READ_VARS - unused_var_set)
# get read variable information from JSON file
rec_vars_path = os.path.join(test_path, '..', 'records_variables.json')
with open(rec_vars_path, 'r', encoding='utf-8') as rvfile:
with open(rec_vars_path, 'r', encoding='utf-8') as rvfile:
read_var_dict = json.load(rvfile)
# create table_dict with sorted read vars followed by sorted calc vars
table_dict = {}
Expand Down
4 changes: 2 additions & 2 deletions taxcalc/tests/test_reforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_2017_law_reform(tests_path):
}
assert isinstance(pre_expect, dict)
assert set(pre_expect.keys()).issubset(set(pre_mdata.keys()))
for name in pre_expect:
for name in pre_expect: # pylint: disable=consider-using-dict-items
aval = pre_mdata[name]
if aval.ndim == 2:
act = aval[0][0] # comparing only first item in a vector parameter
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_round_trip_reforms(fyear, tests_path):
)
fail_params = []
msg = '\nRound-trip-reform and current-law-policy param values differ for:'
for pname in clp_mdata.keys():
for pname in clp_mdata.keys(): # pylint: disable=consider-using-dict-items
rtr_val = rtr_mdata[pname]
clp_val = clp_mdata[pname]
if not np.allclose(rtr_val, clp_val):
Expand Down

0 comments on commit 9c77b54

Please sign in to comment.