From 1d2df59f051590eeb120912c2ad40839abe25a66 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Sun, 5 Jan 2025 17:13:41 -0500 Subject: [PATCH] Fix pylint W0201 and W0212 warnings --- taxcalc.egg-info/PKG-INFO | 4 ++-- taxcalc.egg-info/requires.txt | 2 +- taxcalc/calculator.py | 2 ++ taxcalc/tests/test_consumption.py | 32 +++++++++++++++++++------------ taxcalc/tests/test_data.py | 7 ++++--- taxcalc/tests/test_decorators.py | 3 +++ taxcalc/tests/test_growdiff.py | 11 ++++++----- taxcalc/tests/test_policy.py | 2 +- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index 48da0e9ce..03f61df2c 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -1,7 +1,7 @@ Metadata-Version: 2.1 Name: taxcalc Version: 4.4.0 -Summary: taxcalc +Summary: Tax-Calculator Home-page: https://github.com/PSLmodels/Tax-Calculator Download-URL: https://github.com/PSLmodels/Tax-Calculator License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication @@ -20,7 +20,7 @@ Description-Content-Type: text/markdown License-File: LICENSE Requires-Dist: numpy>=1.26 Requires-Dist: pandas>=2.2 -Requires-Dist: bokeh>=3.6 +Requires-Dist: bokeh>=2.4 Requires-Dist: numba Requires-Dist: paramtools>=0.19.0 diff --git a/taxcalc.egg-info/requires.txt b/taxcalc.egg-info/requires.txt index e78702db6..2cda2894d 100644 --- a/taxcalc.egg-info/requires.txt +++ b/taxcalc.egg-info/requires.txt @@ -1,5 +1,5 @@ numpy>=1.26 pandas>=2.2 -bokeh>=3.6 +bokeh>=2.4 numba paramtools>=0.19.0 diff --git a/taxcalc/calculator.py b/taxcalc/calculator.py index cbce15154..7a1bc5eae 100644 --- a/taxcalc/calculator.py +++ b/taxcalc/calculator.py @@ -1220,7 +1220,9 @@ def lines(text, num_indent_spaces, max_line_length=77): label = _label break if label: + # pylint: disable=protected-access lv = baseline._stateless_label_grid[label] + # pylint: enable=protected-access lv = [ str(item) for item in lv ] diff --git a/taxcalc/tests/test_consumption.py b/taxcalc/tests/test_consumption.py index ca7d53568..7151d1845 100644 --- a/taxcalc/tests/test_consumption.py +++ b/taxcalc/tests/test_consumption.py @@ -40,21 +40,29 @@ def test_update_consumption(): expected_mpc_e20400 = np.full((consump.num_years,), 0.06) expected_mpc_e20400[0] = 0.0 expected_mpc_e20400[1] = 0.05 - assert np.allclose(consump._MPC_e20400, - expected_mpc_e20400, - rtol=0.0) - assert np.allclose(consump._MPC_e17500, - np.zeros((consump.num_years,)), - rtol=0.0) + assert np.allclose( + consump._MPC_e20400, # pylint: disable=protected-access + expected_mpc_e20400, + rtol=0.0 + ) + assert np.allclose( + consump._MPC_e17500, # pylint: disable=protected-access + np.zeros((consump.num_years,)), + rtol=0.0 + ) expected_ben_mcare_value = np.full((consump.num_years,), 0.80) expected_ben_mcare_value[0] = 1.0 expected_ben_mcare_value[1] = 0.75 - assert np.allclose(consump._BEN_mcare_value, - expected_ben_mcare_value, - rtol=0.0) - assert np.allclose(consump._BEN_snap_value, - np.ones((consump.num_years,)), - rtol=0.0) + assert np.allclose( + consump._BEN_mcare_value, # pylint: disable=protected-access + expected_ben_mcare_value, + rtol=0.0 + ) + assert np.allclose( + consump._BEN_snap_value, # pylint: disable=protected-access + np.ones((consump.num_years,)), + rtol=0.0 + ) consump.set_year(2015) assert consump.current_year == 2015 assert consump.MPC_e20400 == 0.06 diff --git a/taxcalc/tests/test_data.py b/taxcalc/tests/test_data.py index 5530ed7b8..906d7862d 100644 --- a/taxcalc/tests/test_data.py +++ b/taxcalc/tests/test_data.py @@ -84,7 +84,7 @@ def _extrapolate(self, year): self, 'e00300', val * self.gfactors.factor_value('AINTS', year) ) - # test Recs class for incorrect instantiation + # test Recs class for incorrect instantiation: with pytest.raises(ValueError): Recs(data=[], start_year=2000, gfactors=None, weights=None) @@ -100,7 +100,7 @@ def _extrapolate(self, year): with pytest.raises(ValueError): Recs(data=cps_subsample, start_year=2000, gfactors='', weights='') - # test Recs class for correct instantiation with no aging of data + # test Recs class for correct instantiation with no aging of data: syr = 2014 rec = Recs(data=cps_subsample, start_year=syr, gfactors=None, weights=None) @@ -132,7 +132,8 @@ def _extrapolate(self, year): assert sum_s006_in_syr_plus_one > sum_s006_in_syr sum_e00300_in_syr_plus_one = getattr(rec, 'e00300').sum() assert sum_e00300_in_syr_plus_one > sum_e00300_in_syr - # test private methods + # test private methods: + # pylint: disable=protected-access rec._read_data(data=None) rec._read_weights(weights=None) with pytest.raises(ValueError): diff --git a/taxcalc/tests/test_decorators.py b/taxcalc/tests/test_decorators.py index 8300807de..9b67b3f2e 100644 --- a/taxcalc/tests/test_decorators.py +++ b/taxcalc/tests/test_decorators.py @@ -155,6 +155,9 @@ def ret_everything(a, b, c, d, e, f): f) +# pylint: disable=attribute-defined-outside-init + + def test_magic_apply_jit(): """Test docstring""" pm = Foo() diff --git a/taxcalc/tests/test_growdiff.py b/taxcalc/tests/test_growdiff.py index 611512a50..7134d7e2f 100644 --- a/taxcalc/tests/test_growdiff.py +++ b/taxcalc/tests/test_growdiff.py @@ -26,10 +26,11 @@ def test_update_and_apply_growdiff(): 2016: 0.02} } gdiff.update_growdiff(diffs) - expected_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02] - extra_years = gdiff.num_years - len(expected_wage_diffs) - expected_wage_diffs.extend([0.02] * extra_years) - assert np.allclose(gdiff._AWAGE, expected_wage_diffs, atol=0.0, rtol=0.0) + exp_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02] + extra_years = gdiff.num_years - len(exp_wage_diffs) + exp_wage_diffs.extend([0.02] * extra_years) + act_wage_diffs = gdiff._AWAGE # pylint: disable=protected-access + assert np.allclose(act_wage_diffs, exp_wage_diffs, atol=0.0, rtol=0.0) # apply growdiff to GrowFactors instance gf = GrowFactors() syr = gdiff.start_year @@ -40,7 +41,7 @@ def test_update_and_apply_growdiff(): gdiff.apply_to(gfactors) pir_pst = gfactors.price_inflation_rates(syr, lyr) wgr_pst = gfactors.wage_growth_rates(syr, lyr) - expected_wgr_pst = [wgr_pre[i] + expected_wage_diffs[i] + expected_wgr_pst = [wgr_pre[i] + exp_wage_diffs[i] for i in range(0, gdiff.num_years)] assert np.allclose(pir_pre, pir_pst, atol=0.0, rtol=0.0) assert np.allclose(wgr_pst, expected_wgr_pst, atol=1.0e-9, rtol=0.0) diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py index 4f40468e5..678b68913 100644 --- a/taxcalc/tests/test_policy.py +++ b/taxcalc/tests/test_policy.py @@ -29,7 +29,7 @@ def cmp_policy_objs(pol1, pol2, year_range=None, exclude=None): else: pol1.clear_state() pol2.clear_state() - for param in pol1._data: + for param in pol1._data: # pylint: disable=protected-access if exclude and param in exclude: continue v1 = getattr(pol1, param)