python/wildcard-import
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Python | warning | none, edit by hand | All versions |
A wildcard import (from module import *) injects every public name from another module into the current namespace, so plain-text search cannot tell where a symbol came from and new exports can silently shadow local names. Import the explicit names you use or qualify them with the module.
from billing.models import *from billing.models import Invoice, OrderWhat the rule reports
Section titled “What the rule reports”The rule reports any from <module> import * statement outside from numpy import *, which numpy/numpy-import-alias already reports with NumPy-specific guidance.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
List each imported symbol explicitly in the from statement, or write import <module> and qualify references with the module name.
Diagnostic message
Section titled “Diagnostic message”Star import from $MOD import * hides where names come from and breaks plain-text search. Import the specific names or import $MOD directly.See all rules in the Python pack.