From 2c59158602f5d36d88c32cefe7e14a3963068c9e Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Mon, 4 Mar 2019 22:43:12 -0800 Subject: Initial work toward fixing issue #873 --- .env | 8 ++++---- .gitignore | 2 +- CHANGELOG.md | 2 ++ isort/isort.py | 4 ++-- isort/main.py | 10 +++------- isort/settings.py | 10 ++++++++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.env b/.env index b9ddb8fe..b491048b 100644 --- a/.env +++ b/.env @@ -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() { @@ -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 diff --git a/.gitignore b/.gitignore index 10fe6e96..2aac988c 100644 --- a/.gitignore +++ b/.gitignore @@ -65,5 +65,5 @@ atlassian-ide-plugin.xml pip-selfcheck.json # Python3 Venv Files -venv/ +.venv/ pyvenv.cfg diff --git a/CHANGELOG.md b/CHANGELOG.md index fc13703d..05adc187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/isort/isort.py b/isort/isort.py index 330755bc..f43aefa2 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -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() @@ -93,7 +93,7 @@ class SortImports(object): 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" diff --git a/isort/main.py b/isort/main.py index 616dc2f0..e6270603 100644 --- a/isort/main.py +++ b/isort/main.py @@ -83,7 +83,7 @@ class SortAttempt(object): 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)) @@ -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 diff --git a/isort/settings.py b/isort/settings.py index e46dbbb5..30d680bd 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -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 -- cgit v1.2.1