@@ -80,35 +80,49 @@ async function findAllFastAPIFiles(
8080async function parsePyprojectForEntryPoint (
8181 folderUri : vscode . Uri ,
8282) : Promise < EntryPoint | null > {
83- const pyprojectUri = vscode . Uri . joinPath ( folderUri , "pyproject.toml" )
83+ const pyprojectTomlFiles = await vscode . workspace . findFiles (
84+ new vscode . RelativePattern ( folderUri , "**/pyproject.toml" ) ,
85+ new vscode . RelativePattern (
86+ folderUri ,
87+ "**/{.venv,venv,__pycache__,node_modules,.git,tests,test}/**" ,
88+ ) ,
89+ )
8490
85- if ( ! ( await vscodeFileSystem . exists ( pyprojectUri . toString ( ) ) ) ) {
91+ if ( pyprojectTomlFiles . length === 0 ) {
8692 return null
8793 }
8894
89- try {
90- const document = await vscode . workspace . openTextDocument ( pyprojectUri )
91- const contents = toml . parse ( document . getText ( ) ) as Record < string , unknown >
95+ pyprojectTomlFiles . sort (
96+ ( a , b ) => a . path . split ( "/" ) . length - b . path . split ( "/" ) . length ,
97+ )
9298
93- const entrypoint = ( contents . tool as Record < string , unknown > | undefined )
94- ?. fastapi as Record < string , unknown > | undefined
95- const entrypointValue = entrypoint ?. entrypoint as string | undefined
99+ for ( const fileUri of pyprojectTomlFiles ) {
100+ try {
101+ const document = await vscode . workspace . openTextDocument ( fileUri )
102+ const contents = toml . parse ( document . getText ( ) ) as Record < string , unknown >
96103
97- if ( ! entrypointValue ) {
98- return null
99- }
104+ const entrypoint = ( contents . tool as Record < string , unknown > | undefined )
105+ ?. fastapi as Record < string , unknown > | undefined
106+ const entrypointValue = entrypoint ?. entrypoint as string | undefined
100107
101- const { relativePath , variableName } =
102- parseEntrypointString ( entrypointValue )
103- const fullUri = vscode . Uri . joinPath ( folderUri , relativePath )
108+ if ( ! entrypointValue ) {
109+ continue
110+ }
104111
105- return ( await vscodeFileSystem . exists ( fullUri . toString ( ) ) )
106- ? { filePath : fullUri . toString ( ) , variableName }
107- : null
108- } catch {
109- // Invalid TOML syntax - silently fall back to auto-detection
110- return null
112+ const { relativePath, variableName } =
113+ parseEntrypointString ( entrypointValue )
114+ const dirUri = vscode . Uri . joinPath ( fileUri , ".." )
115+ const fullUri = vscode . Uri . joinPath ( dirUri , relativePath )
116+
117+ return ( await vscodeFileSystem . exists ( fullUri . toString ( ) ) )
118+ ? { filePath : fullUri . toString ( ) , variableName }
119+ : null
120+ } catch {
121+ // Invalid TOML syntax - silently fall back to next file
122+ }
111123 }
124+
125+ return null
112126}
113127
114128/**
0 commit comments