Skip to content

Commit 9024149

Browse files
Clean up comments and naming
1 parent e77cc01 commit 9024149

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/appDiscovery.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ async function findAllFastAPIFiles(
8080
async function parsePyprojectForEntryPoint(
8181
folderUri: vscode.Uri,
8282
): Promise<EntryPoint | null> {
83-
const pyprojecttomlFiles = await vscode.workspace.findFiles(
83+
const pyprojectTomlFiles = await vscode.workspace.findFiles(
8484
new vscode.RelativePattern(folderUri, "**/pyproject.toml"),
8585
new vscode.RelativePattern(
8686
folderUri,
8787
"**/{.venv,venv,__pycache__,node_modules,.git,tests,test}/**",
8888
),
8989
)
9090

91-
if (pyprojecttomlFiles.length === 0) {
91+
if (pyprojectTomlFiles.length === 0) {
9292
return null
9393
}
9494

95-
pyprojecttomlFiles.sort(
95+
pyprojectTomlFiles.sort(
9696
(a, b) => a.path.split("/").length - b.path.split("/").length,
9797
)
9898

99-
for (const fileUri of pyprojecttomlFiles) {
99+
for (const fileUri of pyprojectTomlFiles) {
100100
try {
101101
const document = await vscode.workspace.openTextDocument(fileUri)
102102
const contents = toml.parse(document.getText()) as Record<string, unknown>
@@ -111,7 +111,8 @@ async function parsePyprojectForEntryPoint(
111111

112112
const { relativePath, variableName } =
113113
parseEntrypointString(entrypointValue)
114-
const fullUri = vscode.Uri.joinPath(fileUri, "..", relativePath)
114+
const dirUri = vscode.Uri.joinPath(fileUri, "..")
115+
const fullUri = vscode.Uri.joinPath(dirUri, relativePath)
115116

116117
return (await vscodeFileSystem.exists(fullUri.toString()))
117118
? { filePath: fullUri.toString(), variableName }

src/core/pathUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ export async function findProjectRoot(
168168
return dirUri
169169
}
170170

171-
// Walk up until we find a directory whose parent doesn't have __init__.py
171+
// __init__.py is present, so this is a traditional package. Walk up until
172+
// we find a directory whose parent doesn't have __init__.py — that parent
173+
// is the project root (the directory Python adds to sys.path).
172174
while (
173175
isWithinDirectory(dirUri, workspaceRootUri) &&
174176
uriPath(dirUri) !== uriPath(workspaceRootUri)

0 commit comments

Comments
 (0)