Skip to content

Commit

Permalink
fix check for in-project-venv
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and radoering committed May 23, 2023
1 parent 88cb826 commit c26cb92
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def get(self, reload: bool = False) -> Env:

if not in_venv or env is not None:
# Checking if a local virtualenv exists
if self.use_in_project_venv():
if self.in_project_venv_exists():
venv = self.in_project_venv

return VirtualEnv(venv)
Expand Down Expand Up @@ -733,7 +733,7 @@ def list(self, name: str | None = None) -> list[VirtualEnv]:
venv_path = self._poetry.config.virtualenvs_path
env_list = [VirtualEnv(p) for p in sorted(venv_path.glob(f"{venv_name}-py*"))]

if self.use_in_project_venv():
if self.in_project_venv_exists():
venv = self.in_project_venv
env_list.insert(0, VirtualEnv(venv))
return env_list
Expand Down Expand Up @@ -852,6 +852,14 @@ def use_in_project_venv(self) -> bool:
in_project: bool | None = self._poetry.config.get("virtualenvs.in-project")
if in_project is not None:
return in_project

return self.in_project_venv.is_dir()

def in_project_venv_exists(self) -> bool:
in_project: bool | None = self._poetry.config.get("virtualenvs.in-project")
if in_project is False:
return False

return self.in_project_venv.is_dir()

def create_venv(
Expand Down

0 comments on commit c26cb92

Please # to comment.