diff --git a/pyproject.toml b/pyproject.toml index 1f58d3117..fb05d1d1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -300,7 +300,6 @@ ignore = [ 'PT019', # Fixture `_mocked_func` without value is injected as parameter, use `@pytest.mark.usefixtures` instead 'PT022', # [*] No teardown in fixture `cmd_in_tty`, use `return` instead of `yield` 'PTH109', # `os.getcwd()` should be replaced by `Path.cwd()` - 'PTH111', # `os.path.expanduser()` should be replaced by `Path.expanduser()` 'PTH118', # `os.path.join()` should be replaced by `Path` with `/` operator 'PTH120', # `os.path.dirname()` should be replaced by `Path.parent` 'PTH122', # `os.path.splitext()` should be replaced by `Path.suffix` diff --git a/src/ansible_navigator/utils/functions.py b/src/ansible_navigator/utils/functions.py index 2136fa583..36d7f6c5b 100644 --- a/src/ansible_navigator/utils/functions.py +++ b/src/ansible_navigator/utils/functions.py @@ -271,7 +271,7 @@ def generate_cache_path(app_name: str) -> Path: :param app_name: Name of application - currently ansible_navigator :returns: Path to the cache directory """ - cache_home = os.environ.get("XDG_CACHE_HOME", f"{os.path.expanduser('~')}/.cache") + cache_home = os.environ.get("XDG_CACHE_HOME", f"{Path.home()}/.cache") return Path(cache_home) / app_name diff --git a/tests/unit/utils/test_functions.py b/tests/unit/utils/test_functions.py index be7ee098f..95e5d6024 100644 --- a/tests/unit/utils/test_functions.py +++ b/tests/unit/utils/test_functions.py @@ -32,9 +32,7 @@ def test_find_many_settings_home(monkeypatch: pytest.MonkeyPatch) -> None: :param monkeypatch: The monkeypatch fixture """ - paths = [ - os.path.join(os.path.expanduser("~"), ".ansible-navigator" + ext) for ext in EXTENSIONS - ] + paths = [os.path.join(Path.home(), ".ansible-navigator" + ext) for ext in EXTENSIONS] def check_path_exists(arg: Any) -> bool: return str(arg) in paths