Hello community, here is the log from the commit of package python-isort for openSUSE:Factory checked in at 2019-03-29 20:34:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-isort (Old) and /work/SRC/openSUSE:Factory/.python-isort.new.25356 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-isort" Fri Mar 29 20:34:31 2019 rev:9 rq:684706 version:4.3.15 Changes: -------- --- /work/SRC/openSUSE:Factory/python-isort/python-isort.changes 2019-03-08 11:59:57.927969486 +0100 +++ /work/SRC/openSUSE:Factory/.python-isort.new.25356/python-isort.changes 2019-03-29 20:34:33.214632054 +0100 @@ -1,0 +2,20 @@ +Wed Mar 13 14:19:07 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 4.3.15: + * Fixed a regression with handling streaming input from pipes (Issue #895) + * Fixed handling of \x0c whitespace character (Issue #811) + * Improved CLI documentation + * Fixed a regression with /directory/.py style patterns + * Fixed the inability to accurately determine import section when a mix of conda and virtual environments are used. + * Fixed some output being printed even when --quiet mode is enabled. + * Fixed issue #890 interoperability with PyCharm by allowing case sensitive non type grouped sorting. + * Fixed issue #889 under some circumstances isort will incorrectly add a new line at the beginning of a file. + * Fixed issue #885 many files not being skipped according to set skip settings. + * Fixed issue #842 streaming encoding improvements. + * Fix error caused when a virtual environment not detected + * 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 + * Improved handling of pex files and other binary Python files + +------------------------------------------------------------------- Old: ---- isort-4.3.10.tar.gz New: ---- isort-4.3.15.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-isort.spec ++++++ --- /var/tmp/diff_new_pack.ZvKTtw/_old 2019-03-29 20:34:34.870632156 +0100 +++ /var/tmp/diff_new_pack.ZvKTtw/_new 2019-03-29 20:34:34.870632156 +0100 @@ -26,7 +26,7 @@ %bcond_with test %endif Name: python-isort%{psuffix} -Version: 4.3.10 +Version: 4.3.15 Release: 0 Summary: A Python utility / library to sort Python imports License: MIT ++++++ isort-4.3.10.tar.gz -> isort-4.3.15.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/CHANGELOG.md new/isort-4.3.15/CHANGELOG.md --- old/isort-4.3.10/CHANGELOG.md 2019-03-03 05:53:49.000000000 +0100 +++ new/isort-4.3.15/CHANGELOG.md 2019-03-11 06:25:21.000000000 +0100 @@ -1,5 +1,30 @@ Changelog ========= +### 4.3.15 - March 10, 2019 - hot fix release +- Fixed a regression with handling streaming input from pipes (Issue #895) +- Fixed handling of \x0c whitespace character (Issue #811) +- Improved CLI documentation + +### 4.3.14 - March 9, 2019 - hot fix release +- Fixed a regression with */directory/*.py style patterns + +### 4.3.13 - March 8, 2019 - hot fix release +- Fixed the inability to accurately determine import section when a mix of conda and virtual environments are used. +- Fixed some output being printed even when --quiet mode is enabled. +- Fixed issue #890 interoperability with PyCharm by allowing case sensitive non type grouped sorting. +- Fixed issue #889 under some circumstances isort will incorrectly add a new line at the beginning of a file. +- Fixed issue #885 many files not being skipped according to set skip settings. +- Fixed issue #842 streaming encoding improvements. + +### 4.3.12 - March 6, 2019 - hot fix release +- Fix error caused when virtual environment not detected + +### 4.3.11 - March 6, 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 +- Improved handling of pex files and other binary Python files + ### 4.3.10 - March 2, 2019 - hot fix release - Fixed Windows incompatibilities (Issue #835) - Fixed relative import sorting bug (Issue #417) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/PKG-INFO new/isort-4.3.15/PKG-INFO --- old/isort-4.3.10/PKG-INFO 2019-03-03 06:07:06.000000000 +0100 +++ new/isort-4.3.15/PKG-INFO 2019-03-11 06:25:58.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: isort -Version: 4.3.10 +Version: 4.3.15 Summary: A Python utility / library to sort Python imports. Home-page: https://github.com/timothycrosley/isort Author: Timothy Crosley @@ -32,6 +32,9 @@ :alt: Join the chat at https://gitter.im/timothycrosley/isort :target: https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge + .. image:: https://pepy.tech/badge/isort + :alt: Downloads + :target: https://pepy.tech/project/isort isort your python imports for you so you don't have to. @@ -677,7 +680,7 @@ Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* +Provides-Extra: requirements Provides-Extra: pipfile Provides-Extra: pyproject -Provides-Extra: requirements Provides-Extra: xdg_home diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/README.rst new/isort-4.3.15/README.rst --- old/isort-4.3.10/README.rst 2019-03-03 02:52:25.000000000 +0100 +++ new/isort-4.3.15/README.rst 2019-03-11 06:25:21.000000000 +0100 @@ -24,6 +24,9 @@ :alt: Join the chat at https://gitter.im/timothycrosley/isort :target: https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +.. image:: https://pepy.tech/badge/isort + :alt: Downloads + :target: https://pepy.tech/project/isort isort your python imports for you so you don't have to. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort/__init__.py new/isort-4.3.15/isort/__init__.py --- old/isort-4.3.10/isort/__init__.py 2019-03-03 06:02:41.000000000 +0100 +++ new/isort-4.3.15/isort/__init__.py 2019-03-11 06:25:21.000000000 +0100 @@ -25,4 +25,4 @@ from . import settings # noqa: F401 from .isort import SortImports # noqa: F401 -__version__ = "4.3.10" +__version__ = "4.3.15" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort/finders.py new/isort-4.3.15/isort/finders.py --- old/isort-4.3.10/isort/finders.py 2019-03-03 05:53:36.000000000 +0100 +++ new/isort-4.3.15/isort/finders.py 2019-03-11 06:25:21.000000000 +0100 @@ -130,16 +130,13 @@ def __init__(self, config, sections): super(PathFinder, self).__init__(config, sections) - # Use a copy of sys.path to avoid any unintended modifications - # to it - e.g. `+=` used below will change paths in place and - # if not copied, consequently sys.path, which will grow unbounded - # with duplicates on every call to this method. - self.paths = list(sys.path) # restore the original import path (i.e. not the path to bin/isort) - self.paths[0] = os.getcwd() + self.paths = [os.getcwd()] # virtual env self.virtual_env = self.config.get('virtual_env') or os.environ.get('VIRTUAL_ENV') + if self.virtual_env: + self.virtual_env = os.path.realpath(self.virtual_env) self.virtual_env_src = False if self.virtual_env: self.virtual_env_src = '{0}/src/'.format(self.virtual_env) @@ -153,6 +150,17 @@ if os.path.isdir(path): self.paths.append(path) + # conda + self.conda_env = self.config.get('conda_env') or os.environ.get('CONDA_PREFIX') + if self.conda_env: + self.conda_env = os.path.realpath(self.conda_env) + for path in glob('{0}/lib/python*/site-packages'.format(self.conda_env)): + if path not in self.paths: + self.paths.append(path) + for path in glob('{0}/lib/python*/*/site-packages'.format(self.conda_env)): + if path not in self.paths: + self.paths.append(path) + # handle case-insensitive paths on windows self.stdlib_lib_prefix = os.path.normcase(sysconfig.get_paths()['stdlib']) if self.stdlib_lib_prefix not in self.paths: @@ -161,12 +169,18 @@ # handle compiled libraries self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so" + # add system paths + for path in sys.path[1:]: + if path not in self.paths: + self.paths.append(path) + def find(self, module_name): for prefix in self.paths: package_path = "/".join((prefix, module_name.split(".")[0])) is_module = (exists_case_sensitive(package_path + ".py") or exists_case_sensitive(package_path + ".so") or - exists_case_sensitive(package_path + self.ext_suffix)) + exists_case_sensitive(package_path + self.ext_suffix) or + exists_case_sensitive(package_path + "/__init__.py")) is_package = exists_case_sensitive(package_path) and os.path.isdir(package_path) if is_module or is_package: if 'site-packages' in prefix: @@ -175,6 +189,8 @@ return self.sections.THIRDPARTY if self.virtual_env and self.virtual_env_src in prefix: return self.sections.THIRDPARTY + if self.conda_env and self.conda_env in prefix: + return self.sections.THIRDPARTY if os.path.normcase(prefix).startswith(self.stdlib_lib_prefix): return self.sections.STDLIB return self.config['default_section'] @@ -297,11 +313,20 @@ def _get_names(self, path): """Load required packages from path to requirements file """ + return RequirementsFinder._get_names_cached(path) + + @classmethod + @lru_cache(maxsize=16) + def _get_names_cached(cls, path): + results = [] + with chdir(os.path.dirname(path)): requirements = parse_requirements(path, session=PipSession()) for req in requirements: if req.name: - yield req.name + results.append(req.name) + + return results class PipfileFinder(ReqsBaseFinder): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort/isort.py new/isort-4.3.15/isort/isort.py --- old/isort-4.3.10/isort/isort.py 2019-03-03 05:53:36.000000000 +0100 +++ new/isort-4.3.15/isort/isort.py 2019-03-11 06:25:21.000000000 +0100 @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function, unicode_literals +import codecs import copy import io import itertools @@ -46,8 +47,9 @@ incorrectly_sorted = False 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): + def __init__(self, file_path=None, file_contents=None, file_=None, write_to_stdout=False, check=False, + show_diff=False, settings_path=None, ask_to_apply=False, run_path='', 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,17 +95,68 @@ self.file_path = file_path or "" if file_path: file_path = os.path.abspath(file_path) - if 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" - " or matches a glob in 'skip_glob' setting".format(file_path)) - file_contents = None - elif not file_contents: - self.file_path = file_path - self.file_encoding = coding_check(file_path) - with io.open(file_path, encoding=self.file_encoding, newline='') as file_to_import_sort: - file_contents = file_to_import_sort.read() + if check_skip: + if run_path and file_path.startswith(run_path): + file_name = file_path.replace(run_path, '', 1) + else: + file_name = file_path + run_path = '' + + if settings.should_skip(file_name, self.config, run_path): + self.skipped = True + if self.config['verbose']: + print("WARNING: {0} was skipped as it's listed in 'skip' setting" + " or matches a glob in 'skip_glob' setting".format(file_path)) + file_contents = None + if not self.skipped and not file_contents: + with io.open(file_path, 'rb') as f: + file_encoding = coding_check(f) + with io.open(file_path, encoding=file_encoding, newline='') as file_to_import_sort: + try: + file_contents = file_to_import_sort.read() + self.file_path = file_path + self.file_encoding = file_encoding + encoding_success = True + except UnicodeDecodeError: + encoding_success = False + + if not encoding_success: + with io.open(file_path, newline='') as file_to_import_sort: + try: + file_contents = file_to_import_sort.read() + self.file_path = file_path + self.file_encoding = file_to_import_sort.encoding + except UnicodeDecodeError: + encoding_success = False + file_contents = None + self.skipped = True + if self.config['verbose']: + print("WARNING: {} was skipped as it couldn't be opened with the given " + "{} encoding or {} fallback encoding".format(file_path, + self.file_encoding, + file_to_import_sort.encoding)) + elif file_: + try: + file_.seek(0) + self.file_encoding = coding_check(file_) + file_.seek(0) + except io.UnsupportedOperation: + pass + reader = codecs.getreader(self.file_encoding) + file_contents = reader(file_).read() + + # try to decode file_contents + if file_contents: + try: + basestring + # python 2 + need_decode = (str, bytes) + except NameError: + # python 3 + need_decode = bytes + + if isinstance(file_contents, need_decode): + file_contents = file_contents.decode(coding_check(file_contents.splitlines())) if file_contents is None or ("isort:" + "skip_file") in file_contents: self.skipped = True @@ -170,8 +223,8 @@ check_output = self.output check_against = file_contents if self.config['ignore_whitespace']: - check_output = check_output.replace(self.line_separator, "").replace(" ", "") - check_against = check_against.replace(self.line_separator, "").replace(" ", "") + check_output = check_output.replace(self.line_separator, "").replace(" ", "").replace("\x0c", "") + check_against = check_against.replace(self.line_separator, "").replace(" ", "").replace("\x0c", "") if check_output.strip() == check_against.strip(): if self.config['verbose']: @@ -198,7 +251,8 @@ if answer in ('quit', 'q'): sys.exit(1) with io.open(self.file_path, encoding=self.file_encoding, mode='w', newline='') as output_file: - print("Fixing {0}".format(self.file_path)) + if not self.config['quiet']: + print("Fixing {0}".format(self.file_path)) output_file.write(self.output) @property @@ -273,7 +327,8 @@ prefix = "B" else: prefix = "C" - module_name = module_name.lower() + if not config['case_sensitive']: + module_name = module_name.lower() if section_name is None or 'length_sort_' + str(section_name).lower() not in config: length_sort = config['length_sort'] else: @@ -962,7 +1017,7 @@ 'isort:imports-' not in last): self.comments['above']['straight'].setdefault(module, []).insert(0, self.out_lines.pop(-1)) - if len(self.out_lines) > 0: + if len(self.out_lines) > 0 and len(self.out_lines) != self._first_comment_index_end: last = self.out_lines[-1].rstrip() else: last = "" @@ -979,19 +1034,16 @@ self.imports[placed_module][import_type][module] = None -def coding_check(fname, default='utf-8'): +def coding_check(lines, default='utf-8'): # see https://www.python.org/dev/peps/pep-0263/ pattern = re.compile(br'coding[:=]\s*([-\w.]+)') - coding = default - with io.open(fname, 'rb') as f: - for line_number, line in enumerate(f, 1): - groups = re.findall(pattern, line) - if groups: - coding = groups[0].decode('ascii') - break - if line_number > 2: - break + for line_number, line in enumerate(lines, 1): + groups = re.findall(pattern, line) + if groups: + return groups[0].decode('ascii') + if line_number > 2: + break - return coding + return default diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort/main.py new/isort-4.3.15/isort/main.py --- old/isort-4.3.10/isort/main.py 2019-03-03 05:53:36.000000000 +0100 +++ new/isort-4.3.15/isort/main.py 2019-03-11 06:25:21.000000000 +0100 @@ -61,6 +61,8 @@ _root, ext = os.path.splitext(path) if ext in ('.py', '.pyi'): return True + if ext in ('.pex', ): + return False # Skip editor backup files. if path.endswith('~'): @@ -97,13 +99,7 @@ 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 dirpath, dirnames, filenames in os.walk(path, topdown=True, followlinks=True): for dirname in list(dirnames): if should_skip(dirname, config, dirpath): skipped.append(dirname) @@ -111,7 +107,8 @@ for filename in filenames: filepath = os.path.join(dirpath, filename) if is_python_file(filepath): - if should_skip(filename, config, dirpath): + relative_file = os.path.relpath(filepath, path) + if should_skip(relative_file, config, path): skipped.append(filename) else: yield filepath @@ -176,7 +173,9 @@ def parse_args(argv=None): parser = argparse.ArgumentParser(description='Sort Python import definitions alphabetically ' - 'within logical sections.') + 'within logical sections. Run with no arguments to run ' + 'interactively. Run with `-` as the first argument to read from ' + 'stdin. Otherwise provide a list of files to sort.') inline_args_group = parser.add_mutually_exclusive_group() parser.add_argument('-a', '--add-import', dest='add_imports', action='append', help='Adds the specified import line to all files, ' @@ -280,6 +279,8 @@ help='Shows verbose output, such as when files are skipped or when a check is successful.') parser.add_argument('--virtual-env', dest='virtual_env', help='Virtual environment to use for determining whether a package is third-party') + parser.add_argument('--conda-env', dest='conda_env', + help='Conda environment to use for determining whether a package is third-party') parser.add_argument('-vn', '--version-number', action='version', version=__version__, help='Returns just the current version number without the logo') parser.add_argument('-w', '--line-width', help='The max length of an import line (used for wrapping long imports).', @@ -293,6 +294,8 @@ parser.add_argument('--unsafe', dest='unsafe', action='store_true', help='Tells isort to look for files in standard library directories, etc. ' 'where it may not be safe to operate in') + parser.add_argument('--case-sensitive', dest='case_sensitive', action='store_true', + help='Tells isort to include casing when sorting module names') parser.add_argument('files', nargs='*', help='One or more Python source files that need their imports sorted.') arguments = {key: value for key, value in vars(parser.parse_args(argv)).items() if value} @@ -314,6 +317,7 @@ '-rc for recursive') sys.exit(1) + arguments['check_skip'] = False if 'settings_path' in arguments: sp = arguments['settings_path'] arguments['settings_path'] = os.path.abspath(sp) if os.path.isdir(sp) else os.path.dirname(os.path.abspath(sp)) @@ -328,7 +332,13 @@ file_names = arguments.pop('files', []) if file_names == ['-']: - SortImports(file_contents=sys.stdin.read(), write_to_stdout=True, **arguments) + try: + # python 3 + file_ = sys.stdin.buffer + except AttributeError: + # python 2 + file_ = sys.stdin + SortImports(file_=file_, write_to_stdout=True, **arguments) else: if not file_names: file_names = ['.'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort/settings.py new/isort-4.3.15/isort/settings.py --- old/isort-4.3.10/isort/settings.py 2019-03-03 05:53:36.000000000 +0100 +++ new/isort-4.3.15/isort/settings.py 2019-03-11 06:25:21.000000000 +0100 @@ -58,7 +58,8 @@ 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]+)/" ) WrapModes = ('GRID', 'VERTICAL', 'HANGING_INDENT', 'VERTICAL_HANGING_INDENT', 'VERTICAL_GRID', 'VERTICAL_GRID_GROUPED', @@ -161,7 +162,8 @@ 'no_lines_before': [], 'no_inline_sort': False, 'ignore_comments': False, - 'safety_excludes': True} + 'safety_excludes': True, + 'case_sensitive': False} @lru_cache() @@ -317,14 +319,19 @@ 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): - return True + if path and 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('\\', '/')): @@ -337,7 +344,7 @@ position = os.path.split(position[0]) for glob in config['skip_glob']: - if fnmatch.fnmatch(filename, glob): + if fnmatch.fnmatch(filename, glob) or fnmatch.fnmatch('/' + filename, glob): return True if not (os.path.isfile(os_path) or os.path.isdir(os_path) or os.path.islink(os_path)): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort.egg-info/PKG-INFO new/isort-4.3.15/isort.egg-info/PKG-INFO --- old/isort-4.3.10/isort.egg-info/PKG-INFO 2019-03-03 06:07:06.000000000 +0100 +++ new/isort-4.3.15/isort.egg-info/PKG-INFO 2019-03-11 06:25:58.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: isort -Version: 4.3.10 +Version: 4.3.15 Summary: A Python utility / library to sort Python imports. Home-page: https://github.com/timothycrosley/isort Author: Timothy Crosley @@ -32,6 +32,9 @@ :alt: Join the chat at https://gitter.im/timothycrosley/isort :target: https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge + .. image:: https://pepy.tech/badge/isort + :alt: Downloads + :target: https://pepy.tech/project/isort isort your python imports for you so you don't have to. @@ -677,7 +680,7 @@ Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* +Provides-Extra: requirements Provides-Extra: pipfile Provides-Extra: pyproject -Provides-Extra: requirements Provides-Extra: xdg_home diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/isort.egg-info/requires.txt new/isort-4.3.15/isort.egg-info/requires.txt --- old/isort-4.3.10/isort.egg-info/requires.txt 2019-03-03 06:07:06.000000000 +0100 +++ new/isort-4.3.15/isort.egg-info/requires.txt 2019-03-11 06:25:58.000000000 +0100 @@ -1,7 +1,7 @@ [:python_version < "3.2"] -backports.functools_lru_cache futures +backports.functools_lru_cache [pipfile] pipreqs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/setup.py new/isort-4.3.15/setup.py --- old/isort-4.3.10/setup.py 2019-03-03 06:02:48.000000000 +0100 +++ new/isort-4.3.15/setup.py 2019-03-11 06:25:21.000000000 +0100 @@ -6,7 +6,7 @@ readme = f.read() setup(name='isort', - version='4.3.10', + version='4.3.15', description='A Python utility / library to sort Python imports.', long_description=readme, author='Timothy Crosley', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/isort-4.3.10/test_isort.py new/isort-4.3.15/test_isort.py --- old/isort-4.3.10/test_isort.py 2019-03-03 05:53:36.000000000 +0100 +++ new/isort-4.3.15/test_isort.py 2019-03-11 06:25:21.000000000 +0100 @@ -2737,24 +2737,65 @@ assert str(tmpdir.join("file2.py")) in out [email protected]("quiet", (False, True)) +def test_quiet(tmpdir, capfd, quiet): + if sys.platform.startswith("win"): + return + from isort.main import main + tmpdir.join("file1.py").write("import re\nimport os") + tmpdir.join("file2.py").write("") + arguments = ["-rc", str(tmpdir)] + if quiet: + arguments.append("-q") + main(arguments) + out, err = capfd.readouterr() + assert not err + assert bool(out) != quiet + + @pytest.mark.parametrize('enabled', (False, True)) def test_safety_excludes(tmpdir, enabled): tmpdir.join("victim.py").write("# ...") - tmpdir.mkdir(".tox").join("verysafe.py").write("# ...") + toxdir = tmpdir.mkdir(".tox") + toxdir.join("verysafe.py").write("# ...") tmpdir.mkdir("lib").mkdir("python3.7").join("importantsystemlibrary.py").write("# ...") + tmpdir.mkdir(".pants.d").join("pants.py").write("import os") config = dict(settings.default.copy(), safety_excludes=enabled) skipped = [] codes = [str(tmpdir)], main.iter_source_code(codes, config, skipped) + + # if enabled files within nested unsafe directories should be skipped file_names = set(os.path.relpath(f, str(tmpdir)) for f in main.iter_source_code([str(tmpdir)], config, skipped)) if enabled: assert file_names == {'victim.py'} - assert len(skipped) == 2 + assert len(skipped) == 3 else: assert file_names == {os.sep.join(('.tox', 'verysafe.py')), - os.sep.join(('lib', 'python3.7', 'importantsystemlibrary.py')), 'victim.py'} + os.sep.join(('lib', 'python3.7', 'importantsystemlibrary.py')), + os.sep.join(('.pants.d', 'pants.py')), + 'victim.py'} assert not skipped + # directly pointing to files within unsafe directories shouldn't skip them either way + file_names = set(os.path.relpath(f, str(toxdir)) for f in main.iter_source_code([str(toxdir)], config, skipped)) + assert file_names == {'verysafe.py'} + + [email protected]('skip_glob_assert', (([], 0, {os.sep.join(('code', 'file.py'))}), (['**/*.py'], 1, {}), + (['*/code/*.py'], 1, {}))) +def test_skip_glob(tmpdir, skip_glob_assert): + skip_glob, skipped_count, file_names = skip_glob_assert + base_dir = tmpdir.mkdir('build') + code_dir = base_dir.mkdir('code') + code_dir.join('file.py').write('import os') + + config = dict(settings.default.copy(), skip_glob=skip_glob) + skipped = [] + file_names = set(os.path.relpath(f, str(base_dir)) for f in main.iter_source_code([str(base_dir)], config, skipped)) + assert len(skipped) == skipped_count + assert file_names == file_names + def test_comments_not_removed_issue_576(): test_input = ('import distutils\n' @@ -2805,3 +2846,45 @@ test_input = ('from os.\\\n' ' path import (join, split)') assert SortImports(file_contents=test_input).output == 'from os.path import join, split\n' + + +def test_ensure_support_for_non_typed_but_cased_alphabetic_sort_issue_890(): + test_input = ('from pkg import BALL\n' + 'from pkg import RC\n' + 'from pkg import Action\n' + 'from pkg import Bacoo\n' + 'from pkg import RCNewCode\n' + 'from pkg import actual\n' + 'from pkg import rc\n' + 'from pkg import recorder\n') + expected_output = ('from pkg import Action\n' + 'from pkg import BALL\n' + 'from pkg import Bacoo\n' + 'from pkg import RC\n' + 'from pkg import RCNewCode\n' + 'from pkg import actual\n' + 'from pkg import rc\n' + 'from pkg import recorder\n') + assert SortImports(file_contents=test_input, case_sensitive=True, order_by_type=False, + force_single_line=True).output == expected_output + + +def test_to_ensure_empty_line_not_added_to_file_start_issue_889(): + test_input = ('# comment\n' + 'import os\n' + '# comment2\n' + 'import sys\n') + assert SortImports(file_contents=test_input).output == test_input + + +def test_to_ensure_correctly_handling_of_whitespace_only_issue_811(capsys): + test_input = ('import os\n' + 'import sys\n' + '\n' + '\x0c\n' + 'def my_function():\n' + ' print("hi")\n') + SortImports(file_contents=test_input, ignore_whitespace=True) + out, err = capsys.readouterr() + assert out == '' + assert err == ''
