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

confused by symlinks pointing to virtualenv gives FIRSTPARTY not THIRDPARTY #876

Closed
brianmay opened this issue Mar 5, 2019 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@brianmay
Copy link
Contributor

brianmay commented Mar 5, 2019

On my box using isort 4.3.10

lrwxrwxrwx 1 brian brian 36 Aug  8  2018 /home/brian/.virtualenvs -> /home/brian/.local/share/virtualenvs

This appears to get isort confused, and it can incorrectly categorize third party imports as first party.

from-type place_module for django_cron returned FIRSTPARTY

If I redo with another virtual environment that doesn't have symlinks it shows:

from-type place_module for django_cron returned THIRDPARTY

Which I believe is correct.

I believe it is failing here: https://github.com/timothycrosley/isort/blob/f6ff653fbf149b67cef1e553940b788a9afa685e/isort/finders.py#L176

Where self.virtual_env_src contains /home/brian/.virtualenvs/energy_rating/src/ and prefix contains /home/brian/.local/share/virtualenvs/energy_rating/src/django-cron

I suspect the solution might be to apply os.path.realpath() on self.virtual_env_src, which would turn it into /home/brian/.local/share/virtualenvs/energy_rating/src and the condition will pass.

@brianmay
Copy link
Contributor Author

brianmay commented Mar 5, 2019

For the record, same problem with latest version from develop branch.

@brianmay
Copy link
Contributor Author

brianmay commented Mar 5, 2019

This should be fixed in #877.

@brianmay brianmay closed this as completed Mar 5, 2019
timothycrosley pushed a commit that referenced this issue Mar 5, 2019
@timothycrosley timothycrosley added the bug Something isn't working label Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants