From 3d70d8f5534392ff3d6cea3afc0a75940b0f7451 Mon Sep 17 00:00:00 2001 From: myusername Date: Wed, 17 May 2023 17:26:04 -0400 Subject: [PATCH 1/3] adding import symbole roles to occurences created by visiting import related nodes --- packages/pyright-scip/src/treeVisitor.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/pyright-scip/src/treeVisitor.ts b/packages/pyright-scip/src/treeVisitor.ts index 42fcd79e7..c757a9127 100644 --- a/packages/pyright-scip/src/treeVisitor.ts +++ b/packages/pyright-scip/src/treeVisitor.ts @@ -485,7 +485,7 @@ export class TreeVisitor extends ParseTreeWalker { const symbol = this.getScipSymbol(node); this.document.occurrences.push( new scip.Occurrence({ - symbol_roles: scip.SymbolRole.ReadAccess, + symbol_roles: scip.SymbolRole.Import | scip.SymbolRole.ReadAccess, symbol: symbol.value, range: parseNodeToRange(node.module, this.fileInfo!.lines).toLsif(), }) @@ -500,7 +500,8 @@ export class TreeVisitor extends ParseTreeWalker { } override visitImportFromAs(node: ImportFromAsNode): boolean { - this.pushNewOccurrence(node, this.getScipSymbol(node)); + const roles = scip.SymbolRole.Import | scip.SymbolRole.ReadAccess; + this.pushNewOccurrence(node, this.getScipSymbol(node), roles); return false; } @@ -510,19 +511,20 @@ export class TreeVisitor extends ParseTreeWalker { override visitImportAs(node: ImportAsNode): boolean { const moduleName = _formatModuleName(node.module); const importInfo = getImportInfo(node.module); + const roles = scip.SymbolRole.Import | scip.SymbolRole.ReadAccess; if ( importInfo && importInfo.resolvedPaths[0] && path.resolve(importInfo.resolvedPaths[0]).startsWith(this.cwd) ) { const symbol = Symbols.makeModuleInit(this.projectPackage, moduleName); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } else { const pythonPackage = this.moduleNameNodeToPythonPackage(node.module); if (pythonPackage) { const symbol = Symbols.makeModuleInit(pythonPackage, moduleName); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } else { // For python packages & modules that we cannot resolve, // we'll just make a local for the file and note that we could not resolve this module. @@ -534,7 +536,7 @@ export class TreeVisitor extends ParseTreeWalker { const symbol = this.getLocalForDeclaration(node, [ `(module): ${moduleName} [unable to resolve module]`, ]); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } } From e613a0db05465cdb9b9a08279c8da9a1e2918267 Mon Sep 17 00:00:00 2001 From: myusername Date: Wed, 24 May 2023 11:44:39 -0400 Subject: [PATCH 2/3] fix enobufs error --- packages/pyright-scip/src/virtualenv/environment.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/pyright-scip/src/virtualenv/environment.ts b/packages/pyright-scip/src/virtualenv/environment.ts index 691f5ed48..5a2de4a71 100644 --- a/packages/pyright-scip/src/virtualenv/environment.ts +++ b/packages/pyright-scip/src/virtualenv/environment.ts @@ -34,9 +34,10 @@ function pipList(): PipInformation[] { function pipBulkShow(names: string[]): string[] { // TODO: This probably breaks with enough names. Should batch them into 512 or whatever the max for bash would be + const maxBuffer = 1024 * 1024 * 10; // 10MB return child_process - .execSync(`${getPipCommand()} show -f ${names.join(' ')}`) - .toString() + .spawnSync(getPipCommand(), ['show', '-f', `${names.join(' ')}`], { maxBuffer }) + .stdout.toString() .split('---'); } From bf3686381ff74402b60ba868b06390c0b8d54053 Mon Sep 17 00:00:00 2001 From: Adam Chrapkowski Date: Mon, 2 Nov 2026 16:25:05 +0000 Subject: [PATCH 3/3] test: resolve temporary fixture paths on macOS --- packages/pyright-scip/test/test-main.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/pyright-scip/test/test-main.ts b/packages/pyright-scip/test/test-main.ts index bff78fb7c..9fcc03477 100644 --- a/packages/pyright-scip/test/test-main.ts +++ b/packages/pyright-scip/test/test-main.ts @@ -274,7 +274,8 @@ version = "16.05"`, } function testImportRoles(): void { - const projectRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'scip-import-roles-')); + // macOS temporary directories can be symlinked; match the analyzer's resolved file paths. + const projectRoot = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'scip-import-roles-'))); try { fs.writeFileSync(path.join(projectRoot, 'local.py'), 'def value():\n return 1\n'); fs.writeFileSync(