def get_python_files(all_files=None): """Gets a list of all Python files in the repository that need linting. Relies on :func:`get_affected_files()` to determine which files should be considered. NOTE: This requires ``git`` to be installed and requires that this is run within the ``git`` repository. :type all_files: list :param all_files: Optional list of files to be linted. :rtype: tuple :returns: A tuple containing two lists. The first list contains all production files, the next all test files. """ if all_files is None: all_files, diff_base = get_affected_files() library_files = [] non_library_files = [] for filename in all_files: if valid_filename(filename): if is_production_filename(filename): library_files.append(filename) else: non_library_files.append(filename) return library_files, non_library_files, diff_base
def main(): """Run pycodestyle on all Python files in the repository.""" git_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).strip() os.chdir(git_root) candidates, _ = get_affected_files() python_files = [candidate for candidate in candidates if candidate.endswith(".py")] if not python_files: print("No Python files to lint, exiting.") else: pycodestyle_command = ["pycodestyle"] + python_files status_code = subprocess.call(pycodestyle_command) sys.exit(status_code)
def main(): """Run pycodestyle on all Python files in the repository.""" git_root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).strip() os.chdir(git_root) candidates, _ = get_affected_files() python_files = [ candidate for candidate in candidates if candidate.endswith('.py') ] if not python_files: print('No Python files to lint, exiting.') else: pycodestyle_command = ['pycodestyle'] + python_files status_code = subprocess.call(pycodestyle_command) sys.exit(status_code)