Python pycodestyle.Checker() Examples
The following are 12
code examples of pycodestyle.Checker().
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_hacking.py From os-win with Apache License 2.0 | 6 votes |
def _run_check(self, code, checker, filename=None): # We are patching pycodestyle (pep8) so that only the check under test # is actually installed. mock_checks = {'physical_line': {}, 'logical_line': {}, 'tree': {}} with mock.patch('pycodestyle._checks', mock_checks): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) # NOTE(sdague): the standard reporter has printing to stdout # as a normal part of check_all, which bleeds through to the # test output stream in an unhelpful way. This blocks that # printing. with mock.patch('pycodestyle.StandardReport.get_file_results'): checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #2
Source File: test_hacking.py From zun with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #3
Source File: autopep8.py From python-netsurv with MIT License | 5 votes |
def _execute_pep8(pep8_options, source): """Execute pycodestyle via python method calls.""" class QuietReport(pycodestyle.BaseReport): """Version of checker that does not print.""" def __init__(self, options): super(QuietReport, self).__init__(options) self.__full_error_results = [] def error(self, line_number, offset, text, check): """Collect errors.""" code = super(QuietReport, self).error(line_number, offset, text, check) if code: self.__full_error_results.append( {'id': code, 'line': line_number, 'column': offset + 1, 'info': text}) def full_error_results(self): """Return error results in detail. Results are in the form of a list of dictionaries. Each dictionary contains 'id', 'line', 'column', and 'info'. """ return self.__full_error_results checker = pycodestyle.Checker('', lines=source, reporter=QuietReport, **pep8_options) checker.check_all() return checker.report.full_error_results()
Example #4
Source File: autopep8.py From python-netsurv with MIT License | 5 votes |
def _execute_pep8(pep8_options, source): """Execute pycodestyle via python method calls.""" class QuietReport(pycodestyle.BaseReport): """Version of checker that does not print.""" def __init__(self, options): super(QuietReport, self).__init__(options) self.__full_error_results = [] def error(self, line_number, offset, text, check): """Collect errors.""" code = super(QuietReport, self).error(line_number, offset, text, check) if code: self.__full_error_results.append( {'id': code, 'line': line_number, 'column': offset + 1, 'info': text}) def full_error_results(self): """Return error results in detail. Results are in the form of a list of dictionaries. Each dictionary contains 'id', 'line', 'column', and 'info'. """ return self.__full_error_results checker = pycodestyle.Checker('', lines=source, reporter=QuietReport, **pep8_options) checker.check_all() return checker.report.full_error_results()
Example #5
Source File: autopep8.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def _execute_pep8(pep8_options, source): """Execute pycodestyle via python method calls.""" class QuietReport(pycodestyle.BaseReport): """Version of checker that does not print.""" def __init__(self, options): super(QuietReport, self).__init__(options) self.__full_error_results = [] def error(self, line_number, offset, text, check): """Collect errors.""" code = super(QuietReport, self).error(line_number, offset, text, check) if code: self.__full_error_results.append( {'id': code, 'line': line_number, 'column': offset + 1, 'info': text}) def full_error_results(self): """Return error results in detail. Results are in the form of a list of dictionaries. Each dictionary contains 'id', 'line', 'column', and 'info'. """ return self.__full_error_results checker = pycodestyle.Checker('', lines=source, reporter=QuietReport, **pep8_options) checker.check_all() return checker.report.full_error_results()
Example #6
Source File: test_hacking.py From magnum with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #7
Source File: pycodechecker.py From crossCobra with MIT License | 5 votes |
def __init__(self, filename): self.checker = Checker(filename)
Example #8
Source File: test_hacking.py From manila with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #9
Source File: test_hacking.py From masakari with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).lstrip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #10
Source File: test_hacking.py From senlin with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #11
Source File: test_hacking.py From cyborg with Apache License 2.0 | 5 votes |
def _run_check(self, code, checker, filename=None): pycodestyle.register_check(checker) lines = textwrap.dedent(code).strip().splitlines(True) checker = pycodestyle.Checker(filename=filename, lines=lines) checker.check_all() checker.report._deferred_print.sort() return checker.report._deferred_print
Example #12
Source File: logic.py From mu with GNU General Public License v3.0 | 4 votes |
def check_code(self): """ Uses PyFlakes and PyCodeStyle to gather information about potential problems with the code in the current tab. """ tab = self._view.current_tab if tab is None: # There is no active text editor so abort. return if tab.path and not tab.path.endswith(".py"): # Only works on Python files, so abort. return tab.has_annotations = not tab.has_annotations if tab.has_annotations: logger.info("Checking code.") self._view.reset_annotations() filename = tab.path if tab.path else _("untitled") builtins = self.modes[self.mode].builtins flake = check_flake(filename, tab.text(), builtins) if flake: logger.info(flake) self._view.annotate_code(flake, "error") pep8 = check_pycodestyle(tab.text()) if pep8: logger.info(pep8) self._view.annotate_code(pep8, "style") self._view.show_annotations() tab.has_annotations = bool(flake or pep8) if not tab.has_annotations: # No problems detected, so confirm this with a friendly # message. ok_messages = [ _("Good job! No problems found."), _("Hurrah! Checker turned up no problems."), _("Nice one! Zero problems detected."), _("Well done! No problems here."), _("Awesome! Zero problems found."), ] self.show_status_message(random.choice(ok_messages)) self._view.set_checker_icon("check-good.png") else: self._view.set_checker_icon("check-bad.png") else: self._view.reset_annotations()