organize_imports
Tidy Python import blocks: sort, deduplicate, remove unused imports, expand star imports, convert relative to absolute, and shorten deep paths. Dry-run preview by default, apply to write changes.
Instructions
Tidy a module's import block structurally (not formatting — black/ruff own that). Pass the file alone; no Position. One mode per call: 'organize' (default) sorts, deduplicates, and drops unused imports; 'expand_star_imports' replaces from m import * with explicit names (follow with 'organize' to prune unused ones); 'relatives_to_absolutes' rewrites relative imports as absolute; 'froms_to_imports' converts from-imports to plain imports; 'handle_long_imports' shortens deep module paths. Defaults to a Dry Run preview; set apply=true to write. An empty blast_radius means the module already conforms.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| mode | No | organize | |
| root | No | ||
| apply | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||