UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

49 lines (38 loc) • 1.11 kB
# Wildcard Import # Detects 'from module import *' which pollutes namespace id: wildcard-import name: Wildcard Import severity: warning category: readability defect_class: safety inline_tier: warning language: python message: "Wildcard import — pollutes namespace, hard to track origin" description: | 'from module import *' makes it unclear where names come from and can cause name collisions. Explicit is better than implicit. ✅ FIX: Import specific names or use module prefix ```python from os import path, getenv # GOOD - explicit import os # GOOD - namespace preserved os.path.join(...) # Clear where this comes from ``` query: | (import_from_statement module_name: (dotted_name) @MODULE (wildcard_import) @WILDCARD) metavars: - MODULE - WILDCARD tags: - readability - best-practice - imports examples: bad: | from os import * # BAD - where does path come from? from numpy import * # BAD - pollutes namespace good: | from os import path, getenv # GOOD - explicit import numpy as np # GOOD - namespace preserved has_fix: false