Skip to content

Latest commit

 

History

History
207 lines (177 loc) · 25.6 KB

File metadata and controls

207 lines (177 loc) · 25.6 KB

Pylance Documentation Index

This is the complete index of Pylance documentation. Use it to find guides, settings references, and diagnostic rule explanations.


How-To Guides

Step-by-step guides for common Pylance workflows and troubleshooting.

Guide Description
Auto-Import Guide Control auto-import suggestions: settings, indexing, and common issues
CI Type Checking Run Pyright in CI to enforce type checking
Copilot + Pylance Workflow Use Pylance MCP tools with Copilot to diagnose and fix Python issues
Dependency Management Reconcile requirements.txt, pyproject.toml, lockfiles, and PEP 723 with what Pylance sees
Editable Installs Make pip install -e work with Pylance
Generated Code Handle generated or dynamic code that Pylance cannot analyze statically
Gradual Strict Adoption Move from off to strict type checking incrementally
Monorepo Setup Configure Pylance for monorepos, multi-root workspaces, and execution environments
Notebook Troubleshooting Fix common Pylance issues in Jupyter notebooks
Performance Tuning Reduce memory use and improve responsiveness
Python Environments Pick the right interpreter, switch venvs, and handle multiple environments (venv, conda, uv, poetry)
Reading Pylance Logs Use trace logging to diagnose import resolution and settings
Remote Development Use Pylance with SSH, WSL, containers, and Codespaces
Settings Troubleshooting Diagnose settings precedence, config file overrides, and common conflicts
Type Narrowing Use isinstance, is None, and type guards to fix type errors
Unresolved Imports Fix reportMissingImports and related import errors
Workspace vs Open-Files Diagnostics Get errors across the whole workspace instead of only open files

Settings Reference

Each page explains one python.analysis.* setting: what it does, accepted values, and when to use it.

Core Settings

Setting Description
typeCheckingMode Baseline strictness level (off, basic, standard, strict)
diagnosticMode Check open files only or the whole workspace
diagnosticSeverityOverrides Override severity of individual diagnostic rules
languageServerMode Trade features for performance (light, default, full)

Import and Path Settings

Setting Description
autoImportCompletions Enable or disable auto-import suggestions in completions
autoSearchPaths Auto-detect src/ directories
extraPaths Additional directories for import resolution
importFormat Prefer absolute or relative imports in auto-imports
stubPath Directory for custom .pyi stub files
typeshedPaths Custom typeshed location

File Scope Settings

Setting Description
include Files and directories to analyze
exclude Files and directories to skip
ignore Files to analyze but suppress diagnostics for

Indexing and Completions

Setting Description
indexing Enable background indexing for auto-imports and workspace symbols
packageIndexDepths Control indexing depth for specific packages
showOnlyDirectDependenciesInAutoImport Limit auto-import completions to direct dependencies
persistAllIndices Cache all indices to disk
regenerateStdLibIndices Force re-index of standard library
userFileIndexingLimit Maximum number of user files to index
includeAliasesFromUserFiles Include re-exported aliases in completions
includeExtraPathSymbolsInSymbolSearch Include extraPaths symbols in workspace search
includeVenvInWorkspaceSymbols Include virtual environment symbols in workspace search

Code Actions and Hints

Setting Description
fixAll Code actions applied on save or fix-all
inlayHints.callArgumentNames Show parameter names at call sites
inlayHints.functionReturnTypes Show inferred return types
inlayHints.pytestParameters Show pytest fixture parameter types
inlayHints.variableTypes Show inferred variable types
enablePytestSupport Enable pytest-aware analysis

Type Evaluation Settings

Setting Description
typeEvaluation.analyzeUnannotatedFunctions Analyze functions without type annotations
typeEvaluation.deprecateTypingAliases Flag deprecated typing aliases (e.g., typing.List)
typeEvaluation.disableBytesTypePromotions Disable implicit bytes promotions
typeEvaluation.enableExperimentalFeatures Enable experimental type-checking features
typeEvaluation.enableReachabilityAnalysis Detect unreachable code
typeEvaluation.enableTypeIgnoreComments Control # type: ignore comments
typeEvaluation.strictDictionaryInference Infer literal dict key/value types
typeEvaluation.strictListInference Infer literal list element types
typeEvaluation.strictParameterNoneValue Require explicit None type for None default parameters
typeEvaluation.strictSetInference Infer literal set element types

Advanced Settings

Setting Description
useLibraryCodeForTypes Infer types from library source when stubs are missing
useNearestConfiguration Use nearest pyrightconfig.json for each file
nodeArguments Extra Node.js arguments for the language server
nodeExecutable Custom Node.js executable path

Diagnostic Rules

Each page explains one Pyright diagnostic rule: what triggers it, code examples, and how to fix or suppress it.

All rules can be configured via diagnosticSeverityOverrides or in pyrightconfig.json.

Rule Description
reportAbstractUsage Instantiating abstract classes or using abstract methods directly
reportArgumentType Argument type incompatible with parameter type
reportAssertAlwaysTrue Assert statement condition is always true
reportAssertTypeFailure assert_type() type mismatch
reportAssignmentType Assignment type incompatible with target
reportAttributeAccessIssue Accessing undefined attributes
reportCallInDefaultInitializer Function calls in default parameter values
reportCallIssue Problems with function or method calls
reportConstantRedefinition Redefining a Final constant
reportDeprecated Using deprecated functions, classes, or parameters
reportDuplicateImport Same module imported more than once
reportFunctionMemberAccess Accessing non-standard attributes on functions
reportGeneralTypeIssues General type incompatibility issues
reportImplicitOverride Method overrides without @override decorator
reportImplicitStringConcatenation Implicit string literal concatenation
reportImportCycles Circular import chains
reportIncompatibleMethodOverride Method override incompatible with base class
reportIncompatibleVariableOverride Variable override incompatible with base class
reportIncompleteStub Stub file has __getattr__ fallback
reportInconsistentOverload Overloaded function inconsistencies
reportIndexIssue Invalid subscript or index operations
reportInvalidStringEscapeSequence Unrecognized escape sequence in string
reportInvalidStubStatement Invalid statements in .pyi stub files
reportInvalidTypeArguments Invalid generic type arguments
reportInvalidTypeForm Invalid type expression syntax
reportInvalidTypeVarUse Incorrect TypeVar usage
reportMatchNotExhaustive match statement missing cases
reportMissingImports Import could not be resolved
reportMissingModuleSource Module found as stub only, no source
reportMissingParameterType Function parameter missing type annotation
reportMissingSuperCall __init__ missing super().__init__() call
reportMissingTypeArgument Generic type used without type arguments
reportMissingTypeStubs No type stubs found for a library
reportOperatorIssue Invalid operator usage for given types
reportOptionalCall Calling a possibly None value
reportOptionalContextManager Using possibly None as context manager
reportOptionalIterable Iterating over possibly None value
reportOptionalMemberAccess Accessing attribute on possibly None value
reportOptionalOperand Using possibly None in an operation
reportOptionalSubscript Indexing a possibly None value
reportOverlappingOverload Overloads with ambiguous overlap
reportPossiblyUnboundVariable Variable may not be bound in all code paths
reportPrivateImportUsage Importing a private symbol from a typed library
reportPrivateUsage Accessing private members (underscore-prefixed)
reportPropertyTypeMismatch Property getter/setter type mismatch
reportRedeclaration Variable declared with incompatible types
reportReturnType Return value incompatible with declared return type
reportTypeCommentUsage Using # type: comments instead of annotations
reportTypedDictNotRequiredAccess Accessing optional TypedDict keys without check
reportUnboundVariable Using an unbound variable
reportUndefinedVariable Using an undefined variable
reportUnhashable Using unhashable type as dict key or set member
reportUninitializedInstanceVariable Instance variable not initialized in __init__
reportUnknownArgumentType Argument has unknown type (strict mode)
reportUnknownLambdaType Lambda has unknown parameter or return type
reportUnknownMemberType Attribute access returns unknown type
reportUnknownParameterType Function parameter has unknown type
reportUnknownVariableType Variable has unknown type (strict mode)
reportUnnecessaryCast cast() call that has no effect
reportUnnecessaryComparison Comparison that always has the same result
reportUnnecessaryContains in check that always has the same result
reportUnnecessaryIsInstance isinstance() check that is always true or false
reportUnnecessaryTypeIgnoreComment # type: ignore on a line with no error
reportUnsupportedDunderAll Unsupported operations on __all__
reportUntypedBaseClass Inheriting from a class with no type information
reportUntypedClassDecorator Class decorator with no type information
reportUntypedFunctionDecorator Function decorator with no type information
reportUntypedNamedTuple Using untyped namedtuple() instead of NamedTuple
reportUnusedCallResult Ignoring return value of a function call
reportUnusedClass Class defined but never used
reportUnusedCoroutine Coroutine created but never awaited
reportUnusedExpression Expression result is unused
reportUnusedFunction Function defined but never called
reportUnusedImport Import not used in the file
reportUnusedVariable Variable assigned but never used
reportWildcardImportFromLibrary Using from lib import * with a library

Type Server Protocol (TSP)

Document Description
TSP docs Type Server Protocol documentation