Skip to content

Remove sync file operation to unblock ext host #22997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isParentPath,
pathExists,
pathExistsSync,
readFileSync,
readFile,
shellExecute,
} from '../externalDependencies';
import { getEnvironmentDirFromPath } from '../commonUtils';
Expand Down Expand Up @@ -63,7 +63,7 @@ async function isLocalPoetryEnvironment(interpreterPath: string): Promise<boolea
return false;
}
const project = path.dirname(envDir);
if (!hasValidPyprojectToml(project)) {
if (!(await hasValidPyprojectToml(project))) {
return false;
}
// The assumption is that we need to be able to run poetry CLI for an environment in order to mark it as poetry.
Expand Down Expand Up @@ -126,7 +126,7 @@ export class Poetry {
*/
public static async getPoetry(cwd: string): Promise<Poetry | undefined> {
// Following check should be performed synchronously so we trigger poetry execution as soon as possible.
if (!hasValidPyprojectToml(cwd)) {
if (!(await hasValidPyprojectToml(cwd))) {
// This check is not expensive and may change during a session, so we need not cache it.
return undefined;
}
Expand Down Expand Up @@ -325,12 +325,12 @@ export async function isPoetryEnvironmentRelatedToFolder(
*
* @param folder Folder to look for pyproject.toml file in.
*/
function hasValidPyprojectToml(folder: string): boolean {
async function hasValidPyprojectToml(folder: string): Promise<boolean> {
const pyprojectToml = path.join(folder, 'pyproject.toml');
if (!pathExistsSync(pyprojectToml)) {
return false;
}
const content = readFileSync(pyprojectToml);
const content = await readFile(pyprojectToml);
if (!content.includes('[tool.poetry]')) {
return false;
}
Expand Down