def run(path, code=None, params=None, **meta): """Check code with pycodestyle. :return list: List of errors. """ parser = get_parser() for option in parser.option_list: if option.dest and option.dest in params: value = params[option.dest] if not isinstance(value, str): continue params[option.dest] = option.convert_value( option, params[option.dest]) P8Style = StyleGuide(reporter=_PycodestyleReport, **params) buf = StringIO(code) return P8Style.input_file(path, lines=buf.readlines())
def run(path, code=None, params=None, **meta): """Check code with pycodestyle. :return list: List of errors. """ parser = get_parser() for option in parser.option_list: if option.dest and option.dest in params: value = params[option.dest] if isinstance(value, str): params[option.dest] = option.convert_value(option, value) for key in ["filename", "exclude", "select", "ignore"]: if key in params and isinstance(params[key], str): params[key] = _parse_multi_options(params[key]) P8Style = StyleGuide(reporter=_PycodestyleReport, **params) buf = StringIO(code) return P8Style.input_file(path, lines=buf.readlines())
def print_files_information_pep8(): """ Print the list of files which can be removed from the whitelist and the list of files which do not respect PEP8 formatting that aren't in the whitelist """ infracting_files = [] non_infracting_files = [] pep8_checker = StyleGuide(quiet=True) for path in list_files(".py"): number_of_infractions = pep8_checker.input_file(path) rel_path = os.path.relpath(path, cleverhans.__path__[0]) if number_of_infractions > 0: if rel_path not in whitelist_pep8: infracting_files.append(path) else: if rel_path in whitelist_pep8: non_infracting_files.append(path) print("Files that must be corrected or added to whitelist:") for file in infracting_files: print(file) print("Files that can be removed from whitelist:") for file in non_infracting_files: print(file)