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

Remove __init__ from import statement when using sqlite autoimport #645

Closed
lieryan opened this issue Jan 9, 2023 · 0 comments · Fixed by #648
Closed

Remove __init__ from import statement when using sqlite autoimport #645

lieryan opened this issue Jan 9, 2023 · 0 comments · Fixed by #648
Labels
bug Unexpected or incorrect user-visible behavior

Comments

@lieryan
Copy link
Member

lieryan commented Jan 9, 2023

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.

@lieryan lieryan added the bug Unexpected or incorrect user-visible behavior label Jan 9, 2023
bagel897 added a commit to bagel897/rope that referenced this issue Jan 15, 2023
@lieryan lieryan changed the title Incorrect sqlite autoimport incorrect import from functions/classes in __init__.py __init__ not removed when using sqlite autoimport Jan 16, 2023
@lieryan lieryan changed the title __init__ not removed when using sqlite autoimport __init__ should be removed when using sqlite autoimport Jan 16, 2023
@lieryan lieryan changed the title __init__ should be removed when using sqlite autoimport Remove __init__ from import statement when using sqlite autoimport Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant