Skip to content

Commit 608effb

Browse files
authored
Remove sync file operation to unblock ext host (#22997)
For #22991
1 parent eff0b3b commit 608effb

File tree

1 file changed

+5
-5
lines changed
  • src/client/pythonEnvironments/common/environmentManagers

1 file changed

+5
-5
lines changed

src/client/pythonEnvironments/common/environmentManagers/poetry.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
isParentPath,
1111
pathExists,
1212
pathExistsSync,
13-
readFileSync,
13+
readFile,
1414
shellExecute,
1515
} from '../externalDependencies';
1616
import { getEnvironmentDirFromPath } from '../commonUtils';
@@ -63,7 +63,7 @@ async function isLocalPoetryEnvironment(interpreterPath: string): Promise<boolea
6363
return false;
6464
}
6565
const project = path.dirname(envDir);
66-
if (!hasValidPyprojectToml(project)) {
66+
if (!(await hasValidPyprojectToml(project))) {
6767
return false;
6868
}
6969
// The assumption is that we need to be able to run poetry CLI for an environment in order to mark it as poetry.
@@ -126,7 +126,7 @@ export class Poetry {
126126
*/
127127
public static async getPoetry(cwd: string): Promise<Poetry | undefined> {
128128
// Following check should be performed synchronously so we trigger poetry execution as soon as possible.
129-
if (!hasValidPyprojectToml(cwd)) {
129+
if (!(await hasValidPyprojectToml(cwd))) {
130130
// This check is not expensive and may change during a session, so we need not cache it.
131131
return undefined;
132132
}
@@ -325,12 +325,12 @@ export async function isPoetryEnvironmentRelatedToFolder(
325325
*
326326
* @param folder Folder to look for pyproject.toml file in.
327327
*/
328-
function hasValidPyprojectToml(folder: string): boolean {
328+
async function hasValidPyprojectToml(folder: string): Promise<boolean> {
329329
const pyprojectToml = path.join(folder, 'pyproject.toml');
330330
if (!pathExistsSync(pyprojectToml)) {
331331
return false;
332332
}
333-
const content = readFileSync(pyprojectToml);
333+
const content = await readFile(pyprojectToml);
334334
if (!content.includes('[tool.poetry]')) {
335335
return false;
336336
}

0 commit comments

Comments
 (0)