reportWildcardImportFromLibrary.md
April 8, 2026 · View on GitHub
Overview
reportWildcardImportFromLibrary is a Pylance and Pyright diagnostic that warns when you use a wildcard import (e.g., from module import *) from a library. Wildcard imports can make code harder to read and maintain, and may introduce unexpected names into your namespace.
Examples
Error:
from os.path import * # Wildcard import from library
result = join("/home", "user") # Works but pollutes namespace
Fix — use explicit imports:
from os.path import join, exists
result = join("/home", "user")
Or import the module and use qualified names:
import os.path
result = os.path.join("/home", "user")
Common Fixes & Workarounds
- Replace wildcard imports with explicit imports of only the names you need.
- Refactor code to avoid relying on
import *from libraries. - Use type annotations and explicit imports for better code clarity and maintainability.
- Refer to the Pyright configuration documentation for details on configuring or disabling this diagnostic.
See Also
python.analysis.diagnosticSeverityOverrides— adjust or suppress this diagnosticpython.analysis.typeCheckingMode— controls which diagnostics are enabled by default