Pin a dependency for all checks that require it. This can
    also resolve transient dependencies.

    Setting the version to `none` will remove the package. You can
    specify an unlimited number of additional checks to apply the
    pin for via arguments.

def pin(package, version, checks, marker, resolving, lazy, quiet):
    """Pin a dependency for all checks that require it. This can
    also resolve transient dependencies.

    Setting the version to `none` will remove the package. You can
    specify an unlimited number of additional checks to apply the
    pin for via arguments.
    """
    root = get_root()
    package_name = package.lower()
    version = version.lower()

    for check_name in sorted(os.listdir(root)):
        pinned_reqs_file = os.path.join(root, check_name, 'requirements.in')
        resolved_reqs_file = os.path.join(root, check_name, 'requirements.txt')

        if os.path.isfile(pinned_reqs_file):
            pinned_packages = {package.name: package for package in read_packages(pinned_reqs_file)}
            if package not in pinned_packages and check_name not in checks:
                continue

            if resolving:
                pre_packages = list(read_packages(resolved_reqs_file))
            else:
                pre_packages = list(itervalues(pinned_packages))

            if not quiet:
                echo_info('Check `{}`:'.format(check_name))

            if version == 'none':
                del pinned_packages[package_name]
            else:
                pinned_packages[package_name] = Package(package_name, version, marker)

            package_list = sorted(itervalues(pinned_packages))
            write_file_lines(pinned_reqs_file, ('{}\n'.format(package) for package in package_list))

            if not quiet:
                echo_waiting('    Resolving dependencies...')

            if resolving:
                result = resolve_requirements(pinned_reqs_file, resolved_reqs_file, lazy=lazy)
                if result.code:
                    abort(result.stdout + result.stderr)

            if not quiet:
                post_packages = read_packages(resolved_reqs_file if resolving else pinned_reqs_file)
                display_package_changes(pre_packages, post_packages, indent='    ')