Skip to content

Commit

Permalink
Fix pylint W0621 and W07073 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jan 6, 2025
1 parent 8131bf5 commit 161a41a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions taxcalc/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ def skip_jit(monkeypatch):
yield


@pytest.fixture(scope='session')
def tests_path():
@pytest.fixture(scope='session', name='tests_path')
def tests_path_fixture():
"""Fixture docstring"""
return os.path.abspath(os.path.dirname(__file__))


@pytest.fixture(scope='session')
def cps_path(tests_path):
@pytest.fixture(scope='session', name='cps_path')
def cps_path_fixture(tests_path):
"""Fixture docstring"""
return os.path.join(tests_path, '..', 'cps.csv.gz')


@pytest.fixture(scope='session')
def cps_fullsample(cps_path):
@pytest.fixture(scope='session', name='cps_fullsample')
def cps_fullsample_fixture(cps_path):
"""Fixture docstring"""
return pandas.read_csv(cps_path)

Expand All @@ -46,14 +46,14 @@ def cps_subsample(cps_fullsample):
return cps_fullsample.sample(frac=0.01, random_state=123456789)


@pytest.fixture(scope='session')
def puf_path(tests_path):
@pytest.fixture(scope='session', name='puf_path')
def puf_path_fixture(tests_path):
"""Fixture docstring"""
return os.path.join(tests_path, '..', '..', 'puf.csv')


@pytest.fixture(scope='session')
def puf_fullsample(puf_path):
@pytest.fixture(scope='session', name='puf_fullsample')
def puf_fullsample_fixture(puf_path):
"""Fixture docstring"""
return pandas.read_csv(puf_path)

Expand Down
10 changes: 5 additions & 5 deletions taxcalc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,8 +1524,8 @@ def read_egg_csv(fname, index_col=None):
path_in_egg = implibres.files('taxcalc').joinpath(fname)
with implibres.as_file(path_in_egg) as rname:
vdf = pd.read_csv(rname, index_col=index_col)
except Exception:
raise ValueError(f'could not read {fname} data from egg')
except Exception as exc:
raise ValueError(f'could not read {fname} data from egg') from exc
# cannot call read_egg_ function in unit tests
return vdf # pragma: no cover

Expand All @@ -1539,8 +1539,8 @@ def read_egg_json(fname):
path_in_egg = implibres.files('taxcalc').joinpath(fname)
with implibres.as_file(path_in_egg) as rname:
pdict = json.loads(rname)
except Exception:
raise ValueError(f'could not read {fname} data from package')
except Exception as exc:
raise ValueError(f'could not read {fname} data from package') from exc
# cannot call read_egg_ function in pytest unit tests
return pdict # pragma: no cover

Expand Down Expand Up @@ -1616,5 +1616,5 @@ def json_to_dict(json_text):
linenum += 1
msg += f'{linenum:04d}{line}\n'
msg += bline + '\n'
raise ValueError(msg)
raise ValueError(msg) from valerr
return ordered_dict

0 comments on commit 161a41a

Please sign in to comment.