python-rope/rope

Remove __init__ from import statement when using sqlite autoimport

lieryan opened this issue · 0 comments

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Code before refactoring:

    # mod1/__init__.py
    def foo():
        pass
  2. And you want to autoimport mod1.foo from mod2.py using sqlite-based autoimport:

    # mod2.py
    foo()
  3. Currently, it seems that sqlite autoimport would suggest this autoimport:

--- a/mod2.py
+++ b/mod2.py
@@ -1 +1,2 @@
+from mod1.__init__ import foo
 foo()
  1. What it should have suggested is this refactoring:
--- a/mod2.py
+++ b/mod2.py
@@ -1 +1,2 @@
+from mod1 import foo
 foo()

Note that the legacy pickle autoimport (which is currently still the default) does the right thing and makes the second suggestion.

Editor information (please complete the following information):

  • Project Python version: 3.10
  • Rope Python version: 3.10
  • Rope version: 1.6.0

Additional context: sqlite autoimport and pickle autoimport has completely different implementation of autoimport, not just the storage backend.