Python pycodestyle.StyleGuide() Examples
The following are 15
code examples of pycodestyle.StyleGuide().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pycodestyle
, or try the search function
.
Example #1
Source File: test_format.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #2
Source File: test_format.py From robust_physical_perturbations with MIT License | 6 votes |
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)
Example #3
Source File: test_format.py From robust_physical_perturbations with MIT License | 6 votes |
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)
Example #4
Source File: test_format.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_format_pep8(): """ Test if pep8 is respected. """ pep8_checker = StyleGuide() files_to_check = [] for path in list_files(".py"): rel_path = os.path.relpath(path, cleverhans.__path__[0]) if rel_path in whitelist_pep8: continue else: files_to_check.append(path) report = pep8_checker.check_files(files_to_check) if report.total_errors > 0: raise AssertionError("PEP8 Format not respected")
Example #5
Source File: pylama_pycodestyle.py From linter-pylama with MIT License | 5 votes |
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())
Example #6
Source File: pycodestyle_checker.py From pyta with GNU General Public License v3.0 | 5 votes |
def process_module(self, node): style_guide = pycodestyle.StyleGuide(paths=[node.stream().name], reporter=JSONReport, ignore=IGNORED_CHECKS) report = style_guide.check_files() for line_num, msg in report.get_file_results(): self.add_message('pep8-errors', line=line_num, args=msg)
Example #7
Source File: test_format.py From robust_physical_perturbations with MIT License | 5 votes |
def test_format_pep8(): """ Test if pep8 is respected. """ pep8_checker = StyleGuide() files_to_check = [] for path in list_files(".py"): rel_path = os.path.relpath(path, cleverhans.__path__[0]) if rel_path in whitelist_pep8: continue else: files_to_check.append(path) report = pep8_checker.check_files(files_to_check) if report.total_errors > 0: raise AssertionError("PEP8 Format not respected")
Example #8
Source File: test_format.py From robust_physical_perturbations with MIT License | 5 votes |
def test_format_pep8(): """ Test if pep8 is respected. """ pep8_checker = StyleGuide() files_to_check = [] for path in list_files(".py"): rel_path = os.path.relpath(path, cleverhans.__path__[0]) if rel_path in whitelist_pep8: continue else: files_to_check.append(path) report = pep8_checker.check_files(files_to_check) if report.total_errors > 0: raise AssertionError("PEP8 Format not respected")
Example #9
Source File: test_code_format.py From nautilus-folder-icons with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.style = pycodestyle.StyleGuide(show_source=True, ignore="E402")
Example #10
Source File: test_code_format.py From Audio-Cutter with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.style = pycodestyle.StyleGuide(show_source=True, ignore="E402")
Example #11
Source File: test_pycodestyle.py From uctf with Apache License 2.0 | 5 votes |
def test_pycodestyle(): style = pycodestyle.StyleGuide() base_path = os.path.dirname(os.path.dirname(__file__)) report = style.check_files([ os.path.join(base_path, 'script', 'control_team_blue'), os.path.join(base_path, 'script', 'control_team_gold'), os.path.join(base_path, 'script', 'rqt_uctf'), os.path.join(base_path, 'script', 'spawn_blue'), os.path.join(base_path, 'script', 'spawn_gold'), os.path.join(base_path, 'src'), os.path.join(base_path, 'test'), ]) assert not report.total_errors
Example #12
Source File: test_linting.py From kademlia with MIT License | 5 votes |
def test_pep8(self): style = pycodestyle.StyleGuide() files = glob('kademlia/**/*.py', recursive=True) result = style.check_files(files) if result.total_errors > 0: raise LintError("Code style errors found.")
Example #13
Source File: test_codestyle.py From transitions with MIT License | 5 votes |
def test_conformance(self): """Test that we conform to PEP-8.""" style = pycodestyle.StyleGuide(quiet=False, ignore=['E501', 'W605']) if exists('transitions'): # when run from root directory (e.g. tox) style.input_dir('transitions') style.input_dir('tests') else: # when run from test directory (e.g. pycharm) style.input_dir('../transitions') style.input_dir('.') result = style.check_files() self.assertEqual(result.total_errors, 0, "Found code style errors (and warnings).")
Example #14
Source File: setup.py From virt-bootstrap with GNU General Public License v3.0 | 5 votes |
def run(self): """ Call pycodestyle and pylint here. """ import pylint.lint import pycodestyle files = ["setup.py", "src/virtBootstrap/", "tests/"] output_format = "colorized" if sys.stdout.isatty() else "text" print(">>> Running pycodestyle ...") style_guide = pycodestyle.StyleGuide(paths=files) report = style_guide.check_files() if style_guide.options.count: sys.stderr.write(str(report.total_errors) + '\n') print(">>> Running pylint ...") pylint_opts = [ "--rcfile", "pylintrc", "--output-format=%s" % output_format ] if self.errors_only: pylint_opts.append("-E") pylint.lint.Run(files + pylint_opts) # SdistCommand is reused from the libvirt python binding (GPLv2+)
Example #15
Source File: test_pep8.py From pynb with MIT License | 5 votes |
def test_pep8(): report = StyleGuide(ignore=['E501', 'E402']).check_files([os.path.dirname(os.path.abspath(__file__)) + '/../']) report.print_statistics() if report.messages: raise Exception("pep8")