Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better story around lint rules modifying imports #358

Open
amyreese opened this issue Jul 15, 2023 · 0 comments
Open

Better story around lint rules modifying imports #358

amyreese opened this issue Jul 15, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@amyreese
Copy link
Member

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.

@amyreese amyreese added the enhancement New feature or request label Jul 15, 2023
@amyreese amyreese added this to the 2.x milestone Jul 15, 2023
@amyreese amyreese self-assigned this Jul 15, 2023
@amyreese amyreese changed the title Better story around lint rules adding imports Better story around lint rules modiying imports Nov 8, 2023
@amyreese amyreese changed the title Better story around lint rules modiying imports Better story around lint rules modifying imports Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant