Better story around lint rules modifying imports
Open
enhancement
- Dominant language
- Python
- Stars
- 714
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
Adding imports with LibCST is a sticky subject because they are normal statements mixed inside `Module.body`. It's not currently possible to do a simple addition with LibCST alongside other changes because that would require replacing the entire root `Module` object with one that contains the new statements, nullifying any other transforms that happened during linting.
Consider offering a mechanism to include any desired additional imports with each reported violation, and then trigger AddImportsVisitor after applying any other autofixes, so that all imports are added at once, and can operate on the already-fixed module object.
Contributor guide
Assessment
This issue has not been assessed yet.