@@ -105,7 +105,7 @@ fn list_all_environments_from_project_config(
105105
106106 // Check if we're allowed to use .venv as a poetry env
107107 // This can be configured in global, project or env variable.
108- // Order of preference is Global, EnvVariable & Project (project wins)
108+ // Order of preference is Project (local config) > EnvVariable > Global
109109 if should_use_local_venv_as_poetry_env ( global, & local, env) {
110110 // If virtualenvs are in the project, then look for .venv
111111 let venv = path. join ( ".venv" ) ;
@@ -121,21 +121,21 @@ fn should_use_local_venv_as_poetry_env(
121121 local : & Option < Config > ,
122122 env : & EnvVariables ,
123123) -> bool {
124- // Given preference to env variable.
125- if let Some ( poetry_virtualenvs_in_project) = env. poetry_virtualenvs_in_project {
124+ // Give preference to setting in local config file (project-level).
125+ if let Some ( poetry_virtualenvs_in_project) =
126+ local. clone ( ) . and_then ( |c| c. virtualenvs_in_project )
127+ {
126128 trace ! (
127- "Poetry virtualenvs_in_project from Env Variable : {}" ,
129+ "Poetry virtualenvs_in_project from local config file : {}" ,
128130 poetry_virtualenvs_in_project
129131 ) ;
130132 return poetry_virtualenvs_in_project;
131133 }
132134
133- // Give preference to setting in local config file.
134- if let Some ( poetry_virtualenvs_in_project) =
135- local. clone ( ) . and_then ( |c| c. virtualenvs_in_project )
136- {
135+ // Then check env variable.
136+ if let Some ( poetry_virtualenvs_in_project) = env. poetry_virtualenvs_in_project {
137137 trace ! (
138- "Poetry virtualenvs_in_project from local config file : {}" ,
138+ "Poetry virtualenvs_in_project from Env Variable : {}" ,
139139 poetry_virtualenvs_in_project
140140 ) ;
141141 return poetry_virtualenvs_in_project;
0 commit comments