-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add the possibility to add import and respect the import sorting. #835
Comments
@charliermarsh, does #875 facilitate the implementation of this issue? |
This would be good to tackle. It has now come up a few times now. I think the idea would be to track the imports that need to be present for a given code modification, and then do a pass at the end to "add" those imports. It would somehow have to be connected to the autofix API too, to ensure that we only add the import if we end up applying the fix. You can see how LibCST handles the problem here. |
There are a few sub-problems:
|
I am returning to this. |
Getting close... diff --git a/foo.py b/foo.py
index 0647ee33b..696a9e873 100644
--- a/foo.py
+++ b/foo.py
@@ -1,3 +1,4 @@
+import sys
exit = 1
-quit(1)
+sys.exit(1) |
sys
module if missing and keep the imports sorted.The text was updated successfully, but these errors were encountered: