Skip to content

Commit 30eb96e

Browse files
authored
Don't inject CWD parent into PATH (#4108)
1 parent 4222108 commit 30eb96e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/ansiblelint/__main__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,11 @@ def path_inject(own_location: str = "") -> None:
450450
inject_paths.append(str(py_path))
451451

452452
# last option, if nothing else is found, just look next to ourselves...
453-
own_location = os.path.realpath(own_location)
454-
if (
455-
own_location
456-
and (Path(own_location).parent / "ansible").exists()
457-
and str(Path(own_location).parent) not in paths
458-
):
459-
inject_paths.append(str(Path(own_location).parent))
453+
if own_location:
454+
own_location = os.path.realpath(own_location)
455+
parent = Path(own_location).parent
456+
if (parent / "ansible").exists() and str(parent) not in paths:
457+
inject_paths.append(str(parent))
460458

461459
if not os.environ.get("PYENV_VIRTUAL_ENV", None):
462460
if inject_paths and not all("pipx" in p for p in inject_paths):

0 commit comments

Comments
 (0)