Priority: P3. Regression in the alias indexing added for #847/#848, reproduced on bab7689.
import importlib as il
from other import *
il.import_module("requests")
The extractor credits requests as a dynamic import. A wildcard import can overwrite il, so the existing conservative rebind rule should drop that alias. The same happens to aliases of import_module and import.
rebinds() already treats from other import * as a possible rebinding of every name. The new identifier index only selects statements mentioning the alias, so the wildcard statement never reaches that check.
Fix: include wildcard-import statements in each alias's candidate statements, retaining the existing scope checks and identifier index for other statements. This restores the pre-indexing behavior. It is intentionally conservative: a wildcard import that does not actually export the alias still loses dynamic-import credit, as before.
A fail-first extractor test covers module/function/import aliases and unchanged no-wildcard controls. It fails on current main and passes with the proposed patch. No real Python application or end-to-end unused-dependency deletion was tested.
Priority: P3. Regression in the alias indexing added for #847/#848, reproduced on bab7689.
The extractor credits requests as a dynamic import. A wildcard import can overwrite il, so the existing conservative rebind rule should drop that alias. The same happens to aliases of import_module and import.
rebinds() already treats
from other import *as a possible rebinding of every name. The new identifier index only selects statements mentioning the alias, so the wildcard statement never reaches that check.Fix: include wildcard-import statements in each alias's candidate statements, retaining the existing scope checks and identifier index for other statements. This restores the pre-indexing behavior. It is intentionally conservative: a wildcard import that does not actually export the alias still loses dynamic-import credit, as before.
A fail-first extractor test covers module/function/import aliases and unchanged no-wildcard controls. It fails on current main and passes with the proposed patch. No real Python application or end-to-end unused-dependency deletion was tested.