diff options
Diffstat (limited to 'isort/settings.py')
-rw-r--r-- | isort/settings.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/isort/settings.py b/isort/settings.py index 68e35a24..b11d2e6b 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -51,7 +51,8 @@ MAX_CONFIG_SEARCH_DEPTH = 25 # The number of parent directories isort will look DEFAULT_SECTIONS = ('FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER') safety_exclude_re = re.compile( - r"/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|lib/python[0-9].[0-9]+)/" + r"/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|\.pants\.d" + r"|lib/python[0-9].[0-9]+)/" ) @@ -373,16 +374,21 @@ def _get_config_data(file_path: str, sections: Iterable[str]) -> Dict[str, Any]: def file_should_be_skipped( filename: str, config: Mapping[str, Any], - path: str = '/' + path: str = '' ) -> bool: - """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): - return True + if config['safety_excludes']: + check_exclude = '/' + filename.replace('\\', '/') + '/' + if path and os.path.basename(path) in ('lib', ): + check_exclude = '/' + os.path.basename(path) + check_exclude + if safety_exclude_re.search(check_exclude): + return True for skip_path in config['skip']: if posixpath.abspath(normalized_path) == posixpath.abspath(skip_path.replace('\\', '/')): |