Skip to content

Commit

Permalink
Avoid confusing modules with executables in bin
Browse files Browse the repository at this point in the history
When an imported module shares the same name as an executable in the
isort script's dir, isort will no longer classify it as a first-party
module, even if bin appears before site-packages in sys.path
  • Loading branch information
dcowgill committed Sep 16, 2013
1 parent 918eb14 commit b149be4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion isort/isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import codecs
import copy
import os
import os.path
from sys import path as PYTHONPATH
from sys import stderr

Expand Down Expand Up @@ -120,7 +121,8 @@ def place_module(self, moduleName):
for prefix in PYTHONPATH:
fixed_module_name = moduleName.replace('.', '/')
base_path = prefix + "/" + fixed_module_name
if os.path.exists(base_path + ".py") or os.path.exists(base_path) or os.path.exists(base_path + ".so"):
if (os.path.exists(base_path + ".py") or os.path.exists(base_path + ".so") or
(os.path.exists(base_path) and os.path.isdir(base_path))):
if "site-packages" in prefix or "dist-packages" in prefix:
return Sections.THIRDPARTY
elif "python2" in prefix.lower() or "python3" in prefix.lower():
Expand Down

0 comments on commit b149be4

Please sign in to comment.