Instagram / Instagram/Fixit

Better story around lint rules modifying imports

Open
#358 0 comments 8 reactions 1 assignee Claimed by @amyreese View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.