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

Issue 1160: remove redundant as imports #1193

Closed
wants to merge 1 commit into from

Conversation

ucodery
Copy link
Collaborator

@ucodery ucodery commented May 7, 2020

No description provided.

@ucodery
Copy link
Collaborator Author

ucodery commented May 7, 2020

I still have an open question as to how this logic would be expected to interact with "keep_direct_and_as_imports", specifically when it is False.
This behavior is changed, but to me the result is pretty obvious

import isort
import isort as isort
# now produces -->
import isort

This behavior is also changed, and IMO makes for cleaner code, but would probably surprise me if I had used the keep_direct_and_as_imports=False option.

import isort as isort
# now produces -->
import isort

Given that the above, simpler code, was achieved without additional special cases in output.py, and that I opened #1192, I have submitted with this new behavior.

@graingert
Copy link
Member

@ucodery
Copy link
Collaborator Author

ucodery commented Jun 2, 2020

@graingert interesting, it is good to see some documentation why this shadowing is used in some places. Given the MyPy convention, would you still agree that the first example is correct? I still see two import lines importing the same thing, and not changing the namespace, as a lint error, and I still see defaulting to the shorter as more straightforward.

@timothycrosley
Copy link
Member

Thanks for all the input and work here! Took the ideas, and additional feedback, and this is now incorporated under this flag: https://timothycrosley.github.io/isort/docs/configuration/options/#remove-redundant-aliases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants