Skip to content

Commit

Permalink
_service/pypi.py: assign pip_cache_dir outside of if statement
Browse files Browse the repository at this point in the history
Assignment expressions are only supported from Python 3.8 and upwards.
Because the if statement consists out of early returns, we can create
another if statement and assign the pip cache directory before the if
statement and after the check for a custom directory has happened.
  • Loading branch information
JeffreyVdb committed Dec 2, 2021
1 parent 00ead12 commit f3f2bcf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pip_audit/_service/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def _get_pip_cache() -> str:
def _get_cache_dir(custom_cache_dir: Optional[Path]) -> str:
if custom_cache_dir is not None:
return str(custom_cache_dir)
elif (
pip_cache_dir := _get_pip_cache() if _PIP_VERSION >= _MINIMUM_PIP_VERSION else None
) is not None: # pragma: no cover

pip_cache_dir = _get_pip_cache() if _PIP_VERSION >= _MINIMUM_PIP_VERSION else None
if pip_cache_dir is not None: # pragma: no cover
return pip_cache_dir
else:
fallback_path = os.path.join(Path.home(), ".pip-audit-cache")
Expand Down

0 comments on commit f3f2bcf

Please sign in to comment.