How to use the isort.settings.should_skip function in isort

To help you get started, we’ve selected a few isort examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github konstellation-io / science-toolkit / vscode / extensions / ms-python.python-2020.3.69010 / pythonFiles / lib / python / isort / main.py View on Github external
def iter_source_code(paths, config, skipped):
    """Iterate over all Python source files defined in paths."""
    if 'not_skip' in config:
        config['skip'] = list(set(config['skip']).difference(config['not_skip']))

    for path in paths:
        if os.path.isdir(path):
            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)
                        dirnames.remove(dirname)
                for filename in filenames:
                    filepath = os.path.join(dirpath, filename)
                    if is_python_file(filepath):
                        relative_file = os.path.relpath(filepath, path)
                        if should_skip(relative_file, config, path):
                            skipped.append(filename)
                        else:
                            yield filepath
        else:
            yield path
github DonJayamanne / pythonVSCode / pythonFiles / isort / main.py View on Github external
def iter_source_code(paths, config, skipped):
    """Iterate over all Python source files defined in paths."""
    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):
                for dirname in list(dirnames):
                    if should_skip(dirname, config, dirpath):
                        skipped.append(dirname)
                        dirnames.remove(dirname)
                for filename in filenames:
                    if filename.endswith('.py'):
                        if should_skip(filename, config, dirpath):
                            skipped.append(filename)
                        else:
                            yield os.path.join(dirpath, filename)
        else:
            yield path
github konstellation-io / science-toolkit / vscode / extensions / ms-python.python-2020.3.69010 / pythonFiles / lib / python / isort / main.py View on Github external
else:
        if not file_names:
            file_names = ['.']
            arguments['recursive'] = True
            if not arguments.get('apply', False):
                arguments['ask_to_apply'] = True

        config = from_path(arguments.get('settings_path', '') or os.path.abspath(file_names[0]) or os.getcwd()).copy()
        config.update(arguments)
        wrong_sorted_files = False
        skipped = []

        if config.get('filter_files'):
            filtered_files = []
            for file_name in file_names:
                if should_skip(file_name, config):
                    skipped.append(file_name)
                else:
                    filtered_files.append(file_name)
            file_names = filtered_files

        if arguments.get('recursive', False):
            file_names = iter_source_code(file_names, config, skipped)
        num_skipped = 0
        if config['verbose'] or config.get('show_logo', False):
            print(INTRO)

        jobs = arguments.get('jobs')
        if jobs:
            import multiprocessing
            executor = multiprocessing.Pool(jobs)
            attempt_iterator = executor.imap(functools.partial(sort_imports, **arguments), file_names)
github DonJayamanne / pythonVSCode / pythonFiles / isort / main.py View on Github external
def iter_source_code(paths, config, skipped):
    """Iterate over all Python source files defined in paths."""
    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):
                for dirname in list(dirnames):
                    if should_skip(dirname, config, dirpath):
                        skipped.append(dirname)
                        dirnames.remove(dirname)
                for filename in filenames:
                    if filename.endswith('.py'):
                        if should_skip(filename, config, dirpath):
                            skipped.append(filename)
                        else:
                            yield os.path.join(dirpath, filename)
        else:
            yield path
github konstellation-io / science-toolkit / vscode / extensions / ms-python.python-2020.3.69010 / pythonFiles / lib / python / isort / main.py View on Github external
"""Iterate over all Python source files defined in paths."""
    if 'not_skip' in config:
        config['skip'] = list(set(config['skip']).difference(config['not_skip']))

    for path in paths:
        if os.path.isdir(path):
            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)
                        dirnames.remove(dirname)
                for filename in filenames:
                    filepath = os.path.join(dirpath, filename)
                    if is_python_file(filepath):
                        relative_file = os.path.relpath(filepath, path)
                        if should_skip(relative_file, config, path):
                            skipped.append(filename)
                        else:
                            yield filepath
        else:
            yield path
github DonJayamanne / pythonVSCode / pythonFiles / isort / main.py View on Github external
def iter_source_code(paths, config, skipped):
    """Iterate over all Python source files defined in paths."""
    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):
                for dirname in list(dirnames):
                    if should_skip(dirname, config, dirpath):
                        skipped.append(dirname)
                        dirnames.remove(dirname)
                for filename in filenames:
                    if filename.endswith('.py'):
                        if should_skip(filename, config, dirpath):
                            skipped.append(filename)
                        else:
                            yield os.path.join(dirpath, filename)
        else:
            yield path