Skip to content

Commit

Permalink
Initial work toward fixing issue #873
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Mar 5, 2019
1 parent bcec89b commit 2c59158
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi
export PROJECT_NAME=$OPEN_PROJECT_NAME
export PROJECT_DIR="$PWD"

if [ ! -d "venv" ]; then
if [ ! -d ".venv" ]; then
if ! hash pyvenv 2>/dev/null; then
function pyvenv()
{
Expand All @@ -31,13 +31,13 @@ if [ ! -d "venv" ]; then
fi

echo "Making venv for $PROJECT_NAME"
pyvenv venv
. venv/bin/activate
pyvenv .venv
. .venv/bin/activate
python setup.py install
pip install -r requirements.txt
fi

. venv/bin/activate
. .venv/bin/activate

# Let's make sure this is a hubflow enabled repo
yes | git hf init >/dev/null 2>/dev/null
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ atlassian-ide-plugin.xml
pip-selfcheck.json

# Python3 Venv Files
venv/
.venv/
pyvenv.cfg
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Changelog
=========
### 4.3.11 - March 3, 2019 - hot fix release
- Fixed issue #876: confused by symlinks pointing to virtualenv gives FIRSTPARTY not THIRDPARTY
- Fixed issue #873: current version skips every file on travis
- Additional caching to reduce performance regression introduced in 4.3.5

### 4.3.10 - March 2, 2019 - hot fix release
- Fixed Windows incompatibilities (Issue #835)
Expand Down
4 changes: 2 additions & 2 deletions isort/isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SortImports(object):
skipped = False

def __init__(self, file_path=None, file_contents=None, write_to_stdout=False, check=False,
show_diff=False, settings_path=None, ask_to_apply=False, **setting_overrides):
show_diff=False, settings_path=None, ask_to_apply=False, check_skip=True, **setting_overrides):
if not settings_path and file_path:
settings_path = os.path.dirname(os.path.abspath(file_path))
settings_path = settings_path or os.getcwd()
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self, file_path=None, file_contents=None, write_to_stdout=False, ch
self.file_path = file_path or ""
if file_path:
file_path = os.path.abspath(file_path)
if settings.should_skip(file_path, self.config):
if check_skip and settings.should_skip(file_path, self.config):
self.skipped = True
if self.config['verbose']:
print("WARNING: {0} was skipped as it's listed in 'skip' setting"
Expand Down
10 changes: 3 additions & 7 deletions isort/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, incorrectly_sorted, skipped):

def sort_imports(file_name, **arguments):
try:
result = SortImports(file_name, **arguments)
result = SortImports(file_name, check_skip=False, **arguments)
return SortAttempt(result.incorrectly_sorted, result.skipped)
except IOError as e:
print("WARNING: Unable to parse file {0} due to {1}".format(file_name, e))
Expand All @@ -97,21 +97,17 @@ def iter_source_code(paths, config, skipped):

for path in paths:
if os.path.isdir(path):
if should_skip(path, config, os.getcwd()):
skipped.append(path)
continue

for dirpath, dirnames, filenames in os.walk(
path, topdown=True, followlinks=True
):
for dirname in list(dirnames):
if should_skip(dirname, config, dirpath):
if should_skip(dirname, config, dirpath, paths):
skipped.append(dirname)
dirnames.remove(dirname)
for filename in filenames:
filepath = os.path.join(dirpath, filename)
if is_python_file(filepath):
if should_skip(filename, config, dirpath):
if should_skip(filename, config, dirpath, paths):
skipped.append(filename)
else:
yield filepath
Expand Down
10 changes: 8 additions & 2 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,22 @@ def _get_config_data(file_path, sections):


def should_skip(filename, config, path=''):
"""Returns True if the file should be skipped based on the passed in settings."""
"""Returns True if the file and/or folder should be skipped based on the passed in settings."""
os_path = os.path.join(path, filename)

normalized_path = os_path.replace('\\', '/')
if normalized_path[1:2] == ':':
normalized_path = normalized_path[2:]

if config['safety_excludes'] and safety_exclude_re.search(normalized_path):
if config['safety_excludes'] and safety_exclude_re.search('/' + filename('\\', '/') + '/'):
return True

for skip_path in config['skip']:
for specified_path in specified_paths:
normalized_specified_path = specified_path.replace('\\', '/')
if normalized_path.startswith(normalized_specified_path):
normalized_path_skip = normalized_specified_path

if posixpath.abspath(normalized_path) == posixpath.abspath(skip_path.replace('\\', '/')):
return True

Expand Down

2 comments on commit 2c59158

@blueyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycrosley
Just a friendly nag from the future about the commit message not being very descriptive (without opening and reading the issue on GitHub) (came here via git-bisecting).

@timothycrosley
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll work on improving commit message quality in the future!

Please sign in to comment.