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

Multiple star imports with clashing names #121

Open
Tracked by #272
isik-kaplan opened this issue Sep 29, 2020 · 4 comments
Open
Tracked by #272

Multiple star imports with clashing names #121

isik-kaplan opened this issue Sep 29, 2020 · 4 comments
Assignees
Labels
bug Something isn't working changelog Changes should be written to the changelog file.
Milestone

Comments

@isik-kaplan
Copy link
Contributor

from _collections import *
from collections import *

print(defaultdict)

Unimport works fine when it comes to finding the correct import module for the variables, but this doesn't help when it comes to clashing names.

The problem can be avoided by running unimport twice with the -r flag, allowing it to turn the above into

from _collections import defaultdict
from collections import defaultdict

and then running again to remove the first unused import, but I think it should be able to do it in a single run without needing to run in twice.

@hakancelikdev hakancelikdev added bug Something isn't working changelog Changes should be written to the changelog file. needs test labels Sep 29, 2020
@shivam-S-bisht
Copy link

You can use alias to the same name imports like
from collections import defaultdict as coll_dd
from _collections import defaultdict as _coll_dd

@isik-kaplan
Copy link
Contributor Author

Since we can simply "fix" the end-users' issue by running unimport twice should we maybe simply run it twice? Maybe with something like --fix-star-collisions. Sometimes the best solution is the easiest solution.

@isik-kaplan
Copy link
Contributor Author

In the light of #150 my previous suggestion is no longer(maybe wasn't ever) plausible. So, scratch that.

@hakancelikdev
Copy link
Owner

This is a bug and needs to be solved without giving the user a choice and avoid running it twice for performance reasons.

@hakancelikdev hakancelikdev self-assigned this Dec 5, 2022
@hakancelikdev hakancelikdev added this to the 0.1.0 milestone Dec 5, 2022
@hakancelikdev hakancelikdev mentioned this issue Dec 5, 2022
9 tasks
@hakancelikdev hakancelikdev mentioned this issue Jun 13, 2023
7 tasks
@hakancelikdev hakancelikdev modified the milestones: 1.0.0, 1.1.0 Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working changelog Changes should be written to the changelog file.
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants