-
Notifications
You must be signed in to change notification settings - Fork 191
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
Recipe for adding an import #46
Comments
We have an additional layer that we use internally which includes an Effectively we are using a separate visitor to gather up all of the import nodes, and then calling visit() on the tree inside visit_Module. Note that across multiple visitors (not transforms, since they return a new tree) nodes are comparable via identity so you can stick nodes you care about in a list/set/dict and then do Long term, one of the things I'd like to see in this repository is a library of transforms that do high-level actions such as adding/removing imports. Sort of a batteries-included set of actions which abstract automated modifications to the next level. I'm super excited about all of that but there's a ton of work that we need to get to before it becomes a reality. |
this is super helpful, thank you @DragonMinded. once your team has the bandwidth, it could be great to have a spectrum channel (or some other place) for libcst questions/conversations. |
For now, we're totally okay with opening issues for questions. Keep 'em coming! |
Curious if you have a preferred way of adding an import to a module. This was a quick solution I put together, but it wouldn't work in a lot of scenarios and is messy:
The text was updated successfully, but these errors were encountered: