VS Code Pylance Cheat Sheet

Sidebar

Programming · VS Code Pylance Cheat Sheet

Pylance, the Python language server, in depth: type checking, search paths, rule severities, auto-import, hints and commands. Checked against Pylance 2026.4.1 installed here; the language sheet covers the most common Python settings and this one goes through the rest. Sheet 20 in the VS Code series.

Setup & Commands

Extension IDms-python.vscode-pylance (version 2026.4.1 here); it works with the Python extension
python.languageServerDefault (uses Pylance when installed), Pylance, Jedi, None
Python: Select InterpreterCommand Palette: Pylance reads packages from the interpreter you pick
Pylance: Go to output channelOpen the log: first place to look for import and indexing problems
Pylance: Start Logging / Stop LoggingCollect detailed logs for a bug report
Pylance: Clear All Persisted IndicesDelete the saved library indices if completions go stale
Pylance: Fold All Docstrings / UnfoldCollapse or expand every docstring in the file
Install Matching Type StubsQuick fix: install a types-… package that supplies missing type information
Generate Dependency FileQuick fix: create a requirements.txt-style file
Pylance: Report Issue…Start a bug report with logs attached

Type Checking

python.analysis.typeCheckingModeoff (default), basic, standard, strict: each adds more checks
offMostly syntax errors, undefined names and import problems
basic / standardAdds type mismatches and return checks; standard also checks narrowing, Any use and private access
strictAdds missing-annotation, Any and completeness checks
python.analysis.diagnosticModeopenFilesOnly (default) or workspace: which files get checked
python.analysis.enableTypeCheckingRecommendationOffer to turn type checking on when annotations are found (default true)
python.analysis.disableTaggedHintsTurn off the grey-out and strike-through hints (default false)
python.analysis.displayEnglishDiagnosticsShow messages in English whatever the display language (default false)

Type Evaluation (python.analysis.typeEvaluation.*)

python.analysis.typeEvaluation.analyzeUnannotatedFunctionsCheck functions that have no annotations (default true)
python.analysis.typeEvaluation.enableTypeIgnoreCommentsHonour # type: ignore comments (default true)
python.analysis.typeEvaluation.strictListInferenceInfer precise list element types, e.g. list[int | str | float] (default false)
python.analysis.typeEvaluation.strictDictionaryInferenceThe same for dictionaries (default false)
python.analysis.typeEvaluation.strictSetInferenceThe same for sets (default false)
python.analysis.typeEvaluation.strictParameterNoneValueA parameter defaulting to None is not implicitly optional (default true)
python.analysis.typeEvaluation.deprecateTypingAliasesFlag typing.List-style aliases (default false)
python.analysis.typeEvaluation.enableReachabilityAnalysisMark code that can never run with a hint (default false)
python.analysis.typeEvaluation.disableBytesTypePromotionsbytearray and memoryview are not treated as bytes (default true)
python.analysis.typeEvaluation.enableExperimentalFeaturesTurn on experimental type features (default false)

Scope & Search Paths

python.analysis.include / python.analysis.excludeFolders or files to analyse / to leave out (default [], meaning the workspace root)
python.analysis.useDefaultExcludesAlso skip common folders such as virtual environments (default true)
python.analysis.ignorePaths whose diagnostics are hidden although they are analysed (default [])
python.analysis.extraPathsExtra folders to search for modules (default [])
python.analysis.autoSearchPathsAdd folders like src automatically (default true)
python.analysis.stubPathFolder for your own type stubs (default typings)
python.analysis.enableEditableInstallsSupport pip install -e packages (default true)
python.analysis.useLibraryCodeForTypesInfer types from library source when no stubs exist (default true)
python.analysis.excludeLibraryDiagnosticsHide problems inside library code (default false)
python.analysis.ignoredPackagesInstalled packages to leave out of analysis (default [])
python.analysis.extraPathsForPythonProjectsPer-project extra paths (default {})

Rule Severities

python.analysis.diagnosticSeverityOverridesAn object of rule: level, e.g. { "reportMissingImports": "warning" }
Levelsnone, information, warning, error (also true / false)
reportMissingImportsImport cannot be resolved (default warning in the schema)
reportMissingModuleSourceStub found but the real package is not installed (default warning)
reportUndefinedVariableName is not defined (default warning)
reportAttributeAccessIssueAttribute does not exist on that type (default error)
reportPossiblyUnboundVariableVariable might not be assigned yet (default error)
reportArgumentTypeWrong argument type in a call (default error)
reportUnusedImport / reportUnusedVariableUnused imports and variables (default none)
reportOptionalMemberAccessAttribute use on a value that may be None (default none)
reportPrivateUsageUse of _private names from outside (default none)
The mode mattersThese are the schema's defaults; the typeCheckingMode you choose changes many of them

Auto-Import & Indexing

python.analysis.autoImportCompletionsSuggest symbols from modules you have not imported yet (default false)
python.analysis.showOnlyDirectDependenciesInAutoImportLimit those to packages in requirements.txt or pyproject.toml (default false)
python.analysis.importFormatabsolute (default) or relative for generated imports
python.analysis.completeFunctionParensAdd () to function completions (default false)
python.analysis.extraCommitCharsLet . and ( accept a completion (default false)
python.analysis.indexingIndex libraries and your files for faster features (default true)
python.analysis.userFileIndexingLimitMost of your own files to index (default 2000)
python.analysis.persistAllIndicesSave library indices to disk between sessions (default true)
python.analysis.userFileIndexFollowSymlinkedFoldersFollow symlinked folders when indexing (default true)
python.analysis.includeAliasesFromUserFilesInclude alias symbols from your files in auto-import (default false)
python.analysis.enableParallelIndexingExperimental faster indexer (default false)

Typing Help & Docstrings

python.analysis.autoIndentAdjust indentation as you type Python (default true)
python.analysis.autoFormatStringsTyping { in a string adds the f prefix (default false)
python.analysis.autoSplitStringsSplitting a string with Enter adds quotes and a continuation (default true)
python.analysis.formatOnTypeStylepep8 (default) or black: indentation inside wrapped brackets
python.analysis.supportRestructuredTextRender reStructuredText in docstrings (default true)
python.analysis.supportDocstringTemplateDocstring templates after typing """ (default false)
python.analysis.enableColorPickerColour picker for #RRGGBB strings (default true)
python.analysis.gotoDefinitionInStringLiteralGo to definition on strings that look like module names (default true)
python.analysis.renameInDocstringsRename symbols inside docstrings too (default false)
python.analysis.generateWithTypeAnnotationAdd annotations to generated code (default false in off mode)
python.analysis.fixAllSource fixes to run in fix all (default [])
[python] defaults shippedPylance sets editor.formatOnType to true and editor.wordBasedSuggestions to off for Python

Inlay Hints, Code Lens & Symbols

python.analysis.inlayHints.variableTypesShow inferred variable types (default false)
python.analysis.inlayHints.functionReturnTypesShow inferred return types (default false)
python.analysis.inlayHints.callArgumentNamesoff (default), partial, all: parameter names at call sites
python.analysis.inlayHints.pytestParametersShow types of pytest fixture parameters (default false)
python.analysis.referencesCodeLensA references count above each definition (default false)
python.analysis.gotoOverrideCodeLensA link above methods that override a base-class member (default false)
python.analysis.includeVenvInWorkspaceSymbolsSearch installed packages in Ctrl+T (default false)
python.analysis.includeExtraPathSymbolsInSymbolSearchInclude extraPaths symbols in Ctrl+T (default false)

Frameworks & Optional Extras

python.analysis.enablePytestSupportUnderstand pytest fixtures (default true)
python.analysis.enableDjangoSupportUnderstand Django ORM-generated members (default false)
python.analysis.supportHtmlEmbeddedPythonLanguage support for Python embedded in HTML (default false)
python.analysis.supportAllPythonDocumentsAlso work in non-file Python documents such as the terminal (default false)
python.analysis.disableBundledStubsAnalyse installed packages directly instead of Pylance's stubs (default false)
python.analysis.cellMagicLanguagesMap IPython %% magics to languages in notebooks (default {})
python.analysis.aiHoverSummaries / python.analysis.aiCodeActions / python.analysis.autoTranslateDocstringsOptional Copilot-powered features (all need Copilot; mostly off by default)
python.analysis.useNearestConfigurationExperimental: use the nearest pyrightconfig.json / pyproject.toml in subfolders (default false)

Pyright Config File & Comments (my knowledge)

pyrightconfig.json or [tool.pyright]A project file (or a table in pyproject.toml) with include, exclude, typeCheckingMode, pythonVersion, venvPath, venv, extraPaths, and rule levels
# type: ignoreSilence all type errors on that line
# pyright: ignore[reportRule]Silence one named rule on that line
# pyright: basic / # pyright: strictSet the checking mode for one file
# pyright: reportMissingImports=falseChange one rule for one file
settings.json vs config fileIf a Pyright config file exists, settings that it defines take priority over the matching VS Code settings

A Reasonable Starter Set (my suggestions, not defaults)

"python.analysis.typeCheckingMode": "basic"A useful middle ground
"python.analysis.autoImportCompletions": trueImport names as you complete them
"python.analysis.inlayHints.functionReturnTypes": trueSee inferred return types
"python.analysis.diagnosticMode": "openFilesOnly"Keep it fast (the default)
"python.analysis.exclude": ["**/venv", "**/.venv"]Make sure virtual environments are left out
"python.analysis.diagnosticSeverityOverrides": { "reportUnusedImport": "information" }Gentle reminder, not a warning
"Import could not be resolved": work down this list
1) Is the right interpreter selected (Python: Select Interpreter)? 2) Is the package installed in that environment (pip list)? 3) For your own modules, is the folder in python.analysis.extraPaths, or is the code in a src folder that autoSearchPaths will find? 4) Check Pylance: Go to output channel. Note the difference between reportMissingImports (the module cannot be found) and reportMissingModuleSource (type information exists but the real package is not installed, so install it).
Pylance is slow or uses lots of CPU
Keep python.analysis.diagnosticMode on openFilesOnly, make sure virtual environments and big data folders are in python.analysis.exclude, lower python.analysis.userFileIndexingLimit for huge workspaces, and run Pylance: Clear All Persisted Indices if indexing seems stuck. Type checking in strict mode on a large project needs more time too.