-
Notifications
You must be signed in to change notification settings - Fork 769
Pylance Configuration Tips
Pylance is a powerful language server with support for IntelliSense features that can help you be more productive when writing Python code with the Python extension in Visual Studio Code. Since enabling the full set of IntelliSense features by default could end up making your development experience feel slower, so the Python extension enables a minimum set of features that allow you to be productive while still having a performant experience. However, depending on how large the workspace you're working on VS Code is, you may want to customize the behavior of Pylance through multiple settings to optimize for performance.
Below are various settings you can change in your workspace settings.json
file (View > Command Palette... and run the "Preferences: Open Workspace Settings (JSON)" command) to disable potentially perf intensive Pylance features in VS Code.
Note: because many features are interconnected, enabling one might consume as many resources as enabling several. This is particularly more relevant for workspace-wide settings, which impact the scope of many of Pylance's features.
/******************************************/
/**** Workspace-wide settings ****/
/******************************************/
// Exclude all files from workspace, enabling IntelliSense support for open files only
"python.analysis.exclude": ["**"],
// Disable indexing for workspace & third-party libraries
"python.analysis.indexing": false,
// Enable problem reporting only for open files, instead of all files in the workspace
"python.analysis.diagnosticMode": "openFilesOnly",
/**************************************/
/**** Features with custom support ****/
/**************************************/
// Disable custom parsing of reStructedText docstrings
"python.analysis.supportRestructuredText": false,
// Disable custom pytest IntelliSense features
"python.analysis.enablePytestSupport": false,
/**********************/
/**** Inlay hints ****/
/*********************/
// Disable inlay hints
"python.analysis.inlayHints.callArgumentNames": "off",
"python.analysis.inlayHints.functionReturnTypes": false,
"python.analysis.inlayHints.pytestParameters": false,
"python.analysis.inlayHints.variableTypes": false,
/************************/
/**** Type features ****/
/***********************/
// Disable type checking diagnostics
"python.analysis.typeCheckingMode": "off",
// Disable extracting type information from library implementations
"python.analysis.useLibraryCodeForTypes": false,
/*************************/
/**** Editor features ****/
/*************************/
// Disable semantic highlighting
"editor.semanticHighlighting.enabled": false,
// Disable occurrences highlighting when selecting a symbol
"editor.occurrencesHighlight": "off",
/************************************/
/*** Less perf intensive features ***/
/************************************/
// Whether to automatically complete parenthesis when accepting a function suggestion
"python.analysis.completeFunctionParens": false,
// Whether to automatically convert a string to an f-string when adding "{}"
"python.analysis.autoFormatStrings": false,
// Whether to enable auto import suggestions
"python.analysis.autoImportCompletions": false,
// Whether to enable code navigation for string literals that look like module names
"python.analysis.gotoDefinitionInStringLiteral": false,