From 697997fa6f6ae42c08c8b5bffba85f33b227eb85 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 8 Dec 2019 12:43:21 -0800 Subject: [PATCH] Added default excludes of `**/node_modules` and `**/__pycache__` because these are almost never intended to be scanned for tracked source files. --- docs/configuration.md | 4 ++-- server/src/analyzer/service.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 4032a3f12..b871a9cb1 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -6,9 +6,9 @@ Relative paths specified within the config file are relative to the config file ## Master Pyright Config Options -**include** [array of paths, optional]: Paths of directories or files that should be included. If no paths are specified, pyright defaults to the directory that contains the config file. Paths may contain wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more characters), or ? (a single character). +**include** [array of paths, optional]: Paths of directories or files that should be included. If no paths are specified, pyright defaults to the directory that contains the config file. Paths may contain wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more characters), or ? (a single character). If no include paths are specified, the root path for the workspace is assumed. -**exclude** [array of paths, optional]: Paths of directories or files that should not be included. These override the includes directories, allowing specific subdirectories to be ignored. Note that files in the exclude paths may still be included in the analysis if they are referenced (imported) by source files that are not excluded. Paths may contain wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more characters), or ? (a single character). +**exclude** [array of paths, optional]: Paths of directories or files that should not be included. These override the includes directories, allowing specific subdirectories to be ignored. Note that files in the exclude paths may still be included in the analysis if they are referenced (imported) by source files that are not excluded. Paths may contain wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more characters), or ? (a single character). If no exclude paths are specified, Pyright automatically excludes the following: `**/node_modules` and `**/__pycache__`. **ignore** [array of paths, optional]: Paths of directories or files whose diagnostic output (errors and warnings) should be suppressed even if they are an included file or within the transitive closure of an included file. Paths may contain wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more characters), or ? (a single character). diff --git a/server/src/analyzer/service.ts b/server/src/analyzer/service.ts index e088f4cce..dac739142 100644 --- a/server/src/analyzer/service.ts +++ b/server/src/analyzer/service.ts @@ -255,6 +255,7 @@ export class AnalyzerService { } const configOptions = new ConfigOptions(projectRoot); + const defaultExcludes = ['**/node_modules', '**/__pycache__']; if (commandLineOptions.fileSpecs.length > 0) { commandLineOptions.fileSpecs.forEach(fileSpec => { @@ -266,6 +267,11 @@ export class AnalyzerService { // files under the execution root path. if (commandLineOptions.executionRoot) { configOptions.include.push(getFileSpec('', commandLineOptions.executionRoot)); + + // Add a few common excludes to avoid long scan times. + defaultExcludes.forEach(exclude => { + configOptions.exclude.push(getFileSpec(exclude, commandLineOptions.executionRoot)); + }); } } @@ -284,6 +290,14 @@ export class AnalyzerService { this._console.log(`No include entries specified; assuming ${ configFilePath }`); configOptions.include.push(getFileSpec('', getDirectoryPath(configFilePath))); } + + // If there was no explicit set of excludes, add a few common ones to avoid long scan times. + if (configOptions.exclude.length === 0) { + defaultExcludes.forEach(exclude => { + this._console.log(`Auto-excluding ${ exclude }`); + configOptions.exclude.push(getFileSpec(exclude, commandLineOptions.executionRoot)); + }); + } } this._updateConfigFileWatcher(); }