def check_file(self, filename): """Process python file looking for indications of problems. :param filename: (str) Python source filename :return: (bool) flag indicating failure """ try: python_file = PythonFile.parse(filename) except SyntaxError as e: print('{filename}:SyntaxError: {error}'.format(filename=filename, error=e)) return True # If the user specifies an invalid severity use comment. severity = Nit.SEVERITY.get(self.options.severity, Nit.COMMENT) should_fail = False fail_threshold = Nit.WARNING if self.options.strict else Nit.ERROR for i, nit in enumerate(self.get_nits(python_file)): if i == 0: print() # Add an extra newline to clean up the output only if we have nits. if nit.severity >= severity: print('{nit}\n'.format(nit=nit)) should_fail |= (nit.severity >= fail_threshold) return should_fail
def check_file(self, filename): """Process python file looking for indications of problems. :param filename: (str) Python source filename :return: (bool) flag indicating failure """ try: python_file = PythonFile.parse(filename) except SyntaxError as e: print('{filename}:SyntaxError: {error}'.format(filename=filename, error=e)) return True # If the user specifies an invalid severity use comment severity = Nit.SEVERITY.get(self.options.severity, Nit.COMMENT) should_fail = False fail_threshold = Nit.WARNING if self.options.strict else Nit.ERROR for i, nit in enumerate(self.get_nits(python_file)): if i == 0: print( ) # add an extra newline to clean up the output only if we have nits if nit.severity >= severity: print('{nit}\n'.format(nit=nit)) should_fail |= (nit.severity >= fail_threshold) return should_fail
def init_file(self, filename, lines, expected, line_offset): super(PantsReporter, self).init_file(filename, lines, expected, line_offset) self._python_file = PythonFile.parse(filename) self._twitter_errors = []